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
Note: The CSS
inherit
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:
Open a new FLA file.
1.
Drag an Accordion component from the Components panel to the Stage.
2.
Use the Property inspector to name and size the Accordion component. For this example, give
3.
the component the instance name accordion.
Drag a TextInput component and a Button component from the Components panel to the
4.
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.
Add the following ActionScript to the frame:
5.
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.
Select Control > Test Movie to see the document before adding style inheritance.
6.
Add the following ActionScript to the end of the frame:
7.
accordion.setStyle("fontStyle", "italic");
Select Control > Test Movie to see the changes.
8.
72
Chapter 5: Customizing Components
value is not supported.
"StyleManager class" on page
721.
Need help?
Do you have a question about the FLASH MX 2004-USING COMPONENTS and is the answer not in the manual?
Questions and answers