User Guide

Using styles to customize component color and text 71
Another option in setting custom style declarations is you can assign the CSSStyleDeclaration
instance directly to the component instances
styleName property and bypass storing the
declaration in
_global.styles. To use this approach, modify the above procedure as follows:
Remove the ActionScript from steps 6 and 7 above.
Modify the ActionScript in step 9 to assign the CSSStyleDeclaration instance directly to the
component instances:
a.setStyle("styleName", styleObj);
b.setStyle("styleName", styleObj);
c.setStyle("styleName", styleObj);
Setting styles for a component class
You can define a class style declaration for any class of component (Button, CheckBox, and so on)
that sets default styles for each instance of that class. You must create the style declaration before
you create the instances. Some components, such as TextArea and TextInput, have class style
declarations predefined by default because their
borderStyle and backgroundColor properties
must be customized.
Caution: If you replace a class style sheet, make sure to add any styles that you want from the old
style sheet; otherwise, they will be overwritten.
The following code creates a class style declaration for CheckBox and sets the color for all check
box instances to blue:
if (_global.styles.CheckBox == undefined) {
_global.styles.CheckBox = new mx.styles.CSSStyleDeclaration();
}
_global.styles.CheckBox.setStyle(“color”, 0x0000FF);
Custom style settings have priority over inherited and global style settings.
Setting inheriting styles on a container
An inheriting style is a style that inherits its value from parent components in the document’s
MovieClip hierarchy. If a text or color style is not set at an instance, custom, or class level, Flash
searches the MovieClip hierarchy for the style value. Thus, if you set styles on a container
component, the contained components inherit these style settings.
The following styles are inheriting styles:
fontFamily
fontSize
fontStyle
fontWeight
textAlign
textIndent
All single-value color styles (for example, themeColor is an inheriting style, but
alternatingRowColors is not)