Category Archives: MovieClip

MovieClip.prototype

Actionscript:
  1. MovieClip.prototype.tint = function(col:uint):void {
  2.     var ct:ColorTransform = transform.colorTransform;
  3.     ct.color = col;
  4.     this.transform.colorTransform = ct;
  5. }
  6.  
  7. var circle:MovieClip = MovieClip(addChild(new MovieClip()));
  8. with (circle.graphics) {
  9.     beginFill(0x123455);
  10.     drawCircle(0,0,50);
  11.     x = 100;
  12.     y = 100;
  13. }
  14.  
  15. circle.tint(0xFF0000);

When AS3 first came out I didn't realize that prototype was still around.... This adds a function called tint() to all MovieClips. You should extend MovieClip instead of using this method.... but it's interesting to see that it's still around. There's an explanation of prototype and the AS3 namespace here.

Also posted in color | Tagged , , , | Leave a comment

MovieClip Random Frame

Actionscript:
  1. myClip.gotoAndStop(int(Math.random() * myClip.totalFrames + 1));

An easy way to make a MovieClip go to a random frame. In the future I may post a demo of this technique.

Also posted in random | Leave a comment