Color Property

Color Property

Flash CS4 ActionScript 3.0 Tutorial


How to Change an Movie Symbol Object's Color with Flash ActionScript



Flash describes colors in ActionScript with hexadecimal values. A color value can be broken down into four sets of characters. Let's say you have a shade of green with a value of 0x99CC66. The first two characters (0x) tell Flash that this is a hexadecimal color value. The next two (99) describe the red channel. The third block (CC) is used for green. The final two characters (66) are for blue.

Hexadecimal Basics

There are 256 possible values for red, 256 values for green and 256 choices for blue. A RGB value in Photoshop of 0,0,0 is the same as 0x000000 in hexadecimal. A RGB value of 255, 255, 255 has an equivalent hexadecimal value of 0xFFFFFF. In other words, 255 (decimal) equals FF in hexadecimal.

Tutorial Elements

Oval shaped Movie Symbol with instance name newColor_mc.


Step One

Add an Oval shape to the workspace.

Step Two

Convert your shape to a Movie Symbol by pressing F8.

Step Three

Select the symbol and open the Properties panel (Cmd/F3 (PC-Ctrl/F3)). Type in the name newColor_mc for the Instance Name.

Step Four

Add a new layer called Actions to the top of the stack.

Step Five

Option double-click (PC - Alt double-click) the keyframe in the Actions layer to open the ActionScript panel.

Step Six

Copy/Paste the following code to the ActionScript panel.

var replaceColor:ColorTransform = new ColorTransform;



Step Seven

Test your movie by pressing Cmd/Return (PC - Ctrl/Enter). The symbol displays in bright red.

Try Different Hexadecimal Values

By substituting other values, such as 0x00FF00 or 0x0000FF, the symbol changes to green or blue. Experiment with a few different values to grasp the concept.

Dissecting the Code

The first line of code establishes a new ColorTransform variable named replaceColor. The next line sets replaceColor to a color value of 0xFF0000 (red). The final line transforms the symbol to the new color by assigning the replaceColor value.


Shutterfly 50 Free Prints 160x600