MACROMEDIA FLASH MX 2004-USING COMPONENTS Use Manual page 951

Using components
Hide thumbs Also See for FLASH MX 2004-USING COMPONENTS:
Table of Contents

Advertisement

Registering skins to styles
The following example creates a component called Shape. This component displays a shape that
is one of two skins: a circle or a square. The skins are registered to the
To register a skin to a style:
Create a new ActionScript file and copy the following code into it:
1.
import mx.core.UIComponent;
class Shape extends UIComponent{
static var symbolName:String = "Shape";
static var symbolOwner:Object = Shape;
var className:String = "Shape";
var themeShape:String = "circle_skin"
function Shape(){
}
function init(Void):Void{
super.init();
}
function createChildren():Void{
setSkin(1, themeShape);
super.createChildren();
}
}
Save the file as Shape.as.
2.
Create a new Flash document and save it as Shape.fla in the same folder as Shape.as
3.
Draw a circle on the Stage, select it, and press F8 to convert it to a movie clip.
4.
Give the circle the name and linkage identifier circle_skin.
Open the circle_skin movie clip and place the following ActionScript on Frame 1 to register the
5.
symbol with the style name
mx.skins.ColoredSkinElement.setColorStyle(this, "themeColor");
Create a new movie clip for the component.
6.
Give the movie clip the name and linkage identifier Shape.
Create two layers. Place a
7.
circle_skin in the second frame.
This is the component movie clip. For more information, see
clip" on page
927.
Open StandardComponents.fla as an external library, and drag the UIComponent movie clip
8.
to the Stage on the second frame of the Shape movie clip (with circle_skin).
Close StandardComponents.fla.
9.
:
themeColor
action in the first frame of the first layer. Place the symbol
stop()
themeColor
"Creating a component movie
Creating the ActionScript class file
style.
951

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flash mx

Table of Contents