User Guide
Using styles to customize component color and text 73
Notice that the fontStyle setting on the Accordion component affects not only the Accordion
text itself but also the text associated with the TextInput and Button components inside the
Accordion component.
Setting global styles
The global style declaration is assigned to all Flash components built with version 2 of the
Macromedia Component Architecture. The _global object has a
style property
(
_global.style) that is an instance of CSSStyleDeclaration. This property acts as the global
style declaration. If you change a property’s value on the global style declaration, the change is
applied to all components in your Flash document.
Caution: Some styles are set on a component class’s CSSStyleDeclaration instance (for example,
the
backgroundColor style of the TextArea and TextInput components). Because the class style
declaration takes precedence over the global style declaration when style values are determined,
setting
backgroundColor on the global style declaration would have no effect on TextArea and
TextInput components. For more information, see “Using global, custom, and class styles in the same
document” on page 73.
To change one or more properties in the global style declaration:
1.
Make sure the document contains at least one component instance.
For more information, see “Adding components to Flash documents” on page 44.
2.
Select a frame in the Timeline on which (or before which) the components appear.
3.
In the Actions panel, use code like the following to change properties on the global style
declaration. You need to list only the properties whose values you want to change, as shown
here:
_global.style.setStyle("color", 0xCC6699);
_global.style.setStyle("themeColor", "haloBlue")
_global.style.setStyle("fontSize",16);
_global.style.setStyle("fontFamily" , "_serif");
4.
Select Control > Test Movie to see the changes.
Using global, custom, and class styles in the same document
If you define a style in only one place in a document, Flash uses that definition when it needs to
know a property’s value. However, one Flash document can have a variety of style settings—style
properties set directly on component instances, custom style declarations, default class style
declarations, inheriting styles, and a global style declaration. In such a situation, Flash determines
the value of a property by looking for its definition in all these places in a specific order.
Flash looks for styles in the following order until a value is found:
1.
Flash looks for a style property on the component instance.
2.
Flash looks at the styleName property of the instance to see if a custom style declaration is
assigned to it.
3.
Flash looks for the property on a default class style declaration.