About color style properties

Color style properties behave differently than non-color properties. All color properties have a name that ends in "Color", for example, backgroundColor, disabledColor, and color. When color style properties are changed, the color is immediately changed on the instance and in all of the appropriate child instances. All other style property changes simply mark the object as needing to be redrawn and changes don't occur until the next frame.

The value of a color style property can be a number, a string, or an object. If it is a number, it represents the RGB value of the color as a hexadecimal number (0xRRGGBB). If the value is a string, it must be a color name.

Color names are strings that map to commonly used colors. New color names can be added by using the StyleManager (see StyleManager class). The following table lists the default color names:

Color name

Value

black

0x000000

white

0xFFFFFF

red

0xFF0000

green

0x00FF00

blue

0x0000FF

magenta

0xFF00FF

yellow

0xFFFF00

cyan

0x00FFFF

Note: If the color name is not defined, the component may not draw correctly.

You can use any legal ActionScript identifier to create your own color names (for example, "WindowText" or "ButtonText"). Use the StyleManager to define new colors, as in the following:

mx.styles.StyleManager.registerColorName("special_blue", 0x0066ff);

Most components cannot handle an object as a color style property value. However, certain components can handle color objects that represent gradients or other color combinations. For more information see the "Using styles" section of each component's entry in Components Dictionary.

You can use class style declarations and color names to easily control the colors of text and symbols on the screen. For example, if you want to provide a display configuration screen that looks like Microsoft Windows, you would define color names like ButtonText and WindowText and class style declarations like Button, CheckBox, and Window. By setting the color style properties in the style declarations to ButtonText and WindowText and providing a user interface so the user can change the values of ButtonText and WindowText you can provide the same color schemes as Micosoft Windows, the Mac OS, or any operating system.