Select the Shape movie clip in the library, select Component Definition from the Library
10.
options menu, and enter the AS 2.0 class Shape.
Test the movie clip with the Shape component on the Stage.
11.
To change the theme color, set the style on the instance. The following code changes the color
of a Shape component with the instance name
shape.setStyle("themeColor",0xff0000);
Draw a square on the Stage and convert it to a movie clip.
12.
Give it the linkage name square_skin, and make sure Export in First Frame is selected.
Note: Because the movie clip isn't placed in the component, Export in First Frame must be
selected so that the skin is available before initialization.
Open the square_skin movie clip and place the following ActionScript on Frame 1 to register
13.
the symbol with the style name
mx.skins.ColoredSkinElement.setColorStyle(this, "themeColor");
Place the following code on the instance of the Shape component on the Stage in the main
14.
Timeline:
onClipEvent(initialize){
themeShape = "square_skin";
}
Test the movie clip with Shape on the Stage. The result should display a red square.
15.
Registering a new style name
If you have created a new style name and it is a color style, add the new name to the
object in the StyleManager.as file (First Run\Classes\mx\styles\StyleManager.as). This example
adds the
shapeColor
// initialize set of inheriting color styles
static var colorStyles:Object =
{
barColor: true,
trackColor: true,
borderColor: true,
buttonColor: true,
color: true,
dateHeaderColor: true,
dateRollOverColor: true,
disabledColor: true,
fillColor: true,
highlightColor: true,
scrollTrackColor: true,
selectedDateColor: true,
shadowColor: true,
strokeColor: true,
symbolBackgroundColor: true,
symbolBackgroundDisabledColor: true,
symbolBackgroundPressedColor: true,
symbolColor: true,
952
Chapter 7: Creating Components
themeColor
style:
to red:
shape
:
colorStyles
Need help?
Do you have a question about the FLASH MX 2004-USING COMPONENTS and is the answer not in the manual?