User Guide
84 Customizing Components
■ Create custom style declarations and apply them to several component instances.
You may want to have groups of components in a document share a style. To do this, you
can create custom style declarations to apply to the components you specify.
For more information, see “Setting custom styles for groups of components” on page 87.
■ Create default class style declarations.
You can define a default class style declaration so that every instance of a class shares a
default appearance.
For more information, see “Setting styles for a component class” on page 89.
■ Use inheriting styles to set styles for components in a portion of a document.
The values of style properties set on containers are inherited by contained components.
For more information, see “Setting inheriting styles on a container” on page 90.
Flash does not display changes made to style properties when you view components on the
Stage using the Live Preview feature. For more information, see “Components in Live
Preview” on page 60.
Setting styles on a component instance
You can write ActionScript code to set and get style properties on any component instance.
The
UIObject.setStyle() and UIObject.getStyle() methods can be called directly from
any UI component. The following syntax specifies a property and value for a component
instance:
instanceName.setStyle("propertyName", value);
For example, the following code sets the accent colors on a Button instance called myButton
that uses the Halo theme:
myButton.setStyle("themeColor", "haloBlue");
NOTE
If the value is a string, it must be enclosed in quotation marks.