40
Chapter 2: Creating Basic Components in Flash MX 2004
In the component’s class file, you must also override the name of the skin. Macromedia
recommends that you apply the skin to your component as a clip parameter in the
constructObject2()
method rather than rely on the timing of the instantiation process. This is
especially true when the component creates child components that rely on the positioning of
the skin.
You can override some or all of the control’s skins. For example, the Button control has the
following basic skins, each representing a state of the control:
•
falseUpSkin
•
falseDownSkin
•
falseOverSkin
•
falseDisabledSkin
•
trueUpSkin
•
trueDownSkin
•
trueOverSkin
•
trueDisabledSkin
Each state is represented as a variable in the class file, or is an inherited variable. By setting the
value of one of these variables, you instruct Flex to apply a new skin, using the symbol name to
find the skin.
When you add a new skin, it should respond to resizing and drawing methods of the component.
For a list of what skins are used by what controls, see each control’s entry in
Developing Flex
Applications
.
This section describes a simple method for changing the skin for one of the states of the standard
Button control. You can use the steps in this procedure to change the skin for any visual control
in Flex.
To create a custom component with a different skin:
1.
In the Flash environment, create a FLA file and set the classpath settings to include the Flex
classes and the local directory. For more information, see
“Changing the Flash classpath”
on page 10
.
2.
Insert a new symbol by selecting Insert > New Symbol. The Create New Symbol dialog box
appears. This new symbol will be the new component.
3.
In the Create New Symbol dialog box, do the following:
a
Select the MovieClip for Behavior option (the default).
b
Select the Export for ActionScript check box.
c
Enter the appropriate name, identifier, and class file in the Name, Identifier, and AS 2.0
Class fields.
d
Clear the Export in First Frame check box.
4.
In Edit Symbols mode for the new symbol, rename the Timeline’s first layer to
main
, and add
a
stop()
action in the Actions Frame.
Содержание FLEX - DEVELOPING COMPONENTS AND THEMES
Страница 1: ...Developing Flex Components and Themes in Flash Authoring ...
Страница 4: ...4 Contents ...
Страница 44: ...44 Chapter 2 Creating Basic Components in Flash MX 2004 ...
Страница 82: ...82 Index ...