Color objects can control colors programmatically, which means you can create dynamically colored elements in your movies. You can change background colors, animate colors over gradations, and allow user control over colors (with sliders, buttons, and so on).

To work effectively with colors, you must understand how to specify color values. ActionScript colors have four parts: red, green, blue, and alpha (or transparency). For the color components?each ranging in value from 0 to 255 (in standard, decimal format)?higher numbers mean brighter colors. When red, green, and blue are all 0, the resulting color is black. When red, green, and blue are all 255, the resulting color is white. When red, green, and blue are all equal, the resulting color is a shade of gray.

The alpha value determines the transparency: a value of 0 is completely transparent, and the maximum value, which depends on the method or property used to set the alpha value, is fully opaque. The maximum value for alpha is 100 when specified using the _alpha property; the maximum alpha value is 255 when specified as part of a color transformation along with RGB components.

For example, a pure blue, fully opaque color would have the following components:

Red: 0, Green: 0, Blue: 255, Alpha: 255

For colors in which you don't want to change the alpha (which defaults to the value set for the object during authoring) you can represent the RGB parts as a single value ranging from 0 to 16777215, but using the hexadecimal equivalent is much more practical.

The hexadecimal representation of an ActionScript color begins with 0x and is followed by six bytes (two bytes each for red, green, and blue), so it takes the form 0xRRGGBB. For example, pure red is 0xFF0000, pure green is 0x00FF00, and pure blue is 0x0000FF. All other colors are some combination of red, green, and blue. For example, a nice lime green is 0xA9FC9C. The Flash Color Mixer panel (Shift + F9) shows the hexadecimal value for the selected color under the swatch in the lower-left portion of the panel, as shown in Figure 3-1.

Figure 3-1. The Color Mixer panel

Hexadecimal format makes it easy to identify the red, green, and blue components of a color. However, you are free to use the decimal equivalent. For example, 11140252 is the decimal equivalent of the hexadecimal number 0xA9FC9C.

    Part I: Local Recipes
    Part II: Remote Recipes