User Guide

72 Chapter 5: Customizing Components
The Style Manager tells Flash whether a style inherits its value. Additional styles can also be added
at runtime as inheriting styles. For more information, see “StyleManager class” on page 721.
Note: The CSS inherit value is not supported.
Inherited styles take priority over global styles.
The following example demonstrates how inheriting styles can be used with an Accordion
component, which is available with Flash MX Professional. (The inheriting styles feature is
supported by both Flash MX and Flash MX Professional.)
To create an Accordion component with styles that are inherited by the components in the
individual Accordion panes:
1.
Open a new FLA file.
2.
Drag an Accordion component from the Components panel to the Stage.
3.
Use the Property inspector to name and size the Accordion component. For this example, give
the component the instance name accordion.
4.
Drag a TextInput component and a Button component from the Components panel to the
Stage. Select the instances on the Stage and delete them.
By dragging the components to the Stage and immediately deleting them, you add the
components to the library and make them available to your document at runtime.
5.
Add the following ActionScript to the frame:
var section1 = accordion.createChild(mx.core.View, "section1", {label:
"First Section"});
var section2 = accordion.createChild(mx.core.View, "section2", {label:
"Second Section"});
var input1 = section1.createChild(mx.controls.TextInput, "input1");
var button1 = section1.createChild(mx.controls.Button, "button1");
input1.text = "Text Input";
button1.label = "Button";
button1.move(0, input1.height + 10);
var input2 = section2.createChild(mx.controls.TextInput, "input2");
var button2 = section2.createChild(mx.controls.Button, "button2");
input2.text = "Text Input";
button2.label = "Button";
button2.move(0, input2.height + 10);
The above code adds two children to the Accordion component and loads each with a
TextInput and Button control, which this example uses to demonstrate style inheritance.
6.
Select Control > Test Movie to see the document before adding style inheritance.
7.
Add the following ActionScript to the end of the frame:
accordion.setStyle("fontStyle", "italic");
8.
Select Control > Test Movie to see the changes.