Flash CS3 Documentation |
|||
| Using ActionScript 2.0 Components > Customizing Components > About skinning components > Linking skin color to styles | |||
The version 2 component framework makes it easy to link a visual asset in a skin element to a style set on the component using the skin. To register a movie clip instance to a style, or an entire skin element to a style, add ActionScript code in the timeline of the skin to call mx.skins.ColoredSkinElement.setColorStyle(targetMovieClip, styleName).
This file is located in the application-level configuration folder. For the exact location on your operating system, see About themes.
For example, drag the RadioButton Assets folder to the target library.
For example, the Assets folder for the RadioButton component is called RadioButton Assets; it has a symbol called RadioButtonAssets, which contains all of the individual asset symbols. If you set Export in First Frame on the RadioButtonAssets symbol, all individual asset symbols will also export in the first frame.
For example, open the States/RadioFalseDisabled symbol.
For this example, change the center graphic, which is an instance of the graphic symbol RadioShape1, to a movie clip symbol; then name it Inner Circle. You do not need to select Export for ActionScript.
It would be good practice, but it is not required, to move the newly created movie clip symbol to the Elements folder of the component assets being edited.
For this example, name the instance innerCircle.
For example, add the following code to the skin element's Timeline.
mx.skins.ColoredSkinElement.setColorStyle(innerCircle, "symbolBackgroundDisabledColor");
In this example you're using a color that already corresponds to an existing style name in the Sample style. Wherever possible, it's best to use style names corresponding to official Cascading Style Sheet standards or styles provided by the Halo and Sample themes.
For this example, repeat these steps for the RadioTrueDisabled skin, but instead of converting the existing graphic to a movie clip, delete the graphic and drag the existing Inner Circle symbol to the RadioTrueDisabled skin element.
For this example, drag two RadioButton components to the Stage, set one to selected, and use ActionScript to set both to disabled in order to see the changes.
For this example, set the property at the global level as follows:
_global.style.setStyle("symbolBackgroundDisabledColor", 0xD9D9D9);
Flash CS3