User Guide
Table Of Contents
- Contents
- Working with Flash MX 2004
- Creating Basic Components in Flash MX 2004
- Creating Advanced Components in Flash MX 2004
- Contents
- About Creating components
- Writing the component’s ActionScript code
- Simple example of a class file
- General process for writing a class file
- Selecting a parent class
- Identifying the class, symbol, and owner names
- About the component instantiation life cycle
- Writing the constructor
- Specifying clip parameters
- Implementing the constructObject2() method
- Implementing the init() method
- Implementing the createChildren() method
- Implementing the commitProperties() method
- Implementing the measure() method
- Implementing the layoutChildren() method
- Implementing the draw() method
- Defining getters and setters
- Component metadata
- Defining component parameters
- Handling events
- Using the Event metadata
- About invalidation
- Skinning custom controls
- Adding styles
- Making components accessible
- Improving component usability
- Best practices when designing a component
- Using the ModalText example
- Troubleshooting
- Index

Creating simple components 29
14.
Insert a blank keyframe in the second frame of the assets layer by selecting the frame, and then
selecting Insert > Timeline > Blank Keyframe. The following figure shows the layers for the
BlueButton symbol:
15.
Find the Button control in the Flex Components list:
If you do not see the Flex Components listed in the Components panel, see “Adding Flex
classes and components to the Flash IDE” on page 8.
16.
Drag the Button control from the Flex Components list onto the second frame of the
assets layer.
Flash adds the Button to the Library as a Compiled Clip asset.
17.
Right-click the BlueButton movie clip in the Library and select Component Definition.
18.
In the Component Definition dialog box, set the AS2.0 Class field to BlueButton.
19.
Click OK.
Flash converts the symbol to a component.
20.
Right-click the component in the Flash Library and select Export SWC File.
21.
Save the new SWC file as BlueButton.swc.
22.
In a text editor, create a new MXML file that contains the following code:
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" xmlns="*">
<BlueButton label="Blue Button" />
</mx:Application>