Actionscript:
-
MovieClip.prototype.tint = function(col:uint):void {
-
var ct:ColorTransform = transform.colorTransform;
-
ct.color = col;
-
this.transform.colorTransform = ct;
-
}
-
-
var circle:MovieClip = MovieClip(addChild(new MovieClip()));
-
with (circle.graphics) {
-
beginFill(0x123455);
-
drawCircle(0,0,50);
-
x = 100;
-
y = 100;
-
}
-
-
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.