Tinting the colour of a MovieClip

Here’s an old snippet that I use quite often to set the tint of a MovieClip. It’s useful if you put all of these sorts of utilities in a class and access them via public static methods. So in a utility class called MovieClipUtils.as you could call:
MovieClipUtils.tint(myMovieClip, 0xff0000, 0.5);

[code]
//Color an MC with option amount  (0-1)
public static function tint(target:MovieClip, color:Number, amount:Number = 1):void
{
//create a new Color object
var c:Color=new Color();
//set the color of the tint and set the multiplier
c.setTint(color, amount);
//apply the tint to the colorTransform property of the desired MovieClip/DisplayObject
target.transform.colorTransform = c; //mc is a MovieClip
}
[/code]

Leave a Reply

Your email address will not be published. Required fields are marked *