To change the color of an entire symbol is very easy. You have to get the symbol’s ColorTransform, adjust it, and re-assign the ColorTransform back to the symbol.

The following is a class that you can inherit that allows fairly easy color transformation. Just read the comments to see how the parts work. One interesting feature of the ColorTransform class which is not shown is the concat() operation which allows you to additively combine ColorTransform’s together.

package  
{
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.filters.GlowFilter;
	import flash.geom.ColorTransform;
	public class colorIt extends MovieClip
	{
		public function colorIt() 
		{
			addEventListener(Event.ADDED_TO_STAGE, addHnd, false, 0, true);
		}

		private function addHnd(e:Event):void 
		{
			// get this symbol's ColorTransform 
			var colorTransform:ColorTransform = this.transform.colorTransform;

			// This will change the color of all layers and all sub-symbols within this symbol:
			colorTransform.color = 0xff0000;

			// This will shift the green channel only (-255 to 255).  There is also a redOffset and blueOffset.
			// colorTransform.greenOffset = 100;

			// This number will multiply by the green channel only (decimal value).  There is also a redMultiplier and blueMultiplier.
			// This will essentially saturate/desaturate the color channel.
			// colorTransform.greenMultiplier = 2;

			// re-assign the ColorTransform back to this symbol
			this.transform.colorTransform = colorTransform;
		}
	}
}

– 30 –

Advertisements