April 29, 2009

How to change a movie clip color using ActionScript 3.0

This is a function that changes the color of a video given as a parameter in a new color given as parameter as well.

ActionScript 3.0 code:

import flash.geom.ColorTransform; // import ColorTransform class function setColor(_mc:MovieClip, color):void {     var newColor:ColorTransform = _mc.transform.colorTransform;     newColor.color = color;     _mc.transform.colorTransform = newColor; } setColor(bigBtn.icon.bg, 0xff0000); //call the function