12 Nov 2010

Tinting the colour of a MovieClip

AIR AS3 No Comments

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);

//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
}
No Responses to “Tinting the colour of a MovieClip”

Leave a Reply