Chapter 3. Color


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 ...

Get Actionscript Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.