User Guide
88 Customizing Components
To create a custom style declaration for a group of components:
1. Add at least one component to the Stage.
For more information, see “Adding components to Flash documents” on page 50.
This example uses three button components with the instance names
a, b, and c. If you
use different components, give them instance names in the Property inspector and use
those instance names in step 8.
2. Select a frame in the Timeline on which (or before which) the component appears.
3. Open the Actions panel.
4. Add the following import statement so you will have access to the constructor function for
creating a new style declaration from within the CSSStyleDeclaration class:
import mx.styles.CSSStyleDeclaration;
5.
Use the following syntax to create an instance of the CSSStyleDeclaration object to define
the new custom style format:
var new_style:Object = new CSSStyleDeclaration();
6.
Give your style declaration a name, like “myStyle,” in the _global.styles list of custom
style declarations, and identify the object containing all the properties for your new style
declaration.
_global.styles.myStyle = new_style;
7.
Use the setStyle() method (inherited from the UIObject class) to add properties to the
new_style object, which are in turn associated with the custom style declaration myStyle:
new_style.setStyle("fontFamily", "_serif");
new_style.setStyle("fontSize", 14);
new_style.setStyle("fontWeight", "bold");
new_style.setStyle("textDecoration", "underline");
new_style.setStyle("color", 0x666699);
8.
In the same Script pane, use the following syntax to set the styleName property of three
specific components to the custom style declaration name:
a.setStyle("styleName", "myStyle");
b.setStyle("styleName", "myStyle");
c.setStyle("styleName", "myStyle");