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

Exporting components 21
If the component’s ActionScript classes are in a package, you must specify a namespace that points
to that package in your MXML file, as the following example shows:
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"
xmlns:myp="myPackage.*" >
<myp:myComponent />
</mx:Application>
For more information on using namespaces for Flex components, see Developing Flex Applications.
To pass properties to the component, add them as tag properties, as the following example shows:
<ModalText labelPlacement="left"/>
You can instantiate a custom component by creating the component’s class in ActionScript using
the
createClassObject() method:
<mx:Script>
<![CDATA[
createClassObject(MyComponent, "myComp", 0, {myName:"Ted"});
]]>
</mx:Script>
The previous example is equivalent to the following MXML statement:
<MyComponent id="myComp" myName="Ted" />
Including debugging information
The SWD file contains debugging information for the SWF file. You must use SWD files to use
the Debug Flash Player to debug your component. By default, Flash does not include debugging
information when exporting the SWC file.
When you export a SWC file, you can include the SWD file in the SWC file by selecting
Debugging Permitted in the Publish Settings dialog box. As with all settings in the Publish
Settings dialog box, you must make this change for every FLA file. It is not a global setting.
Note: You should not include debugging information in your SWC file if the SWC file is used in a
production environment. It increases the size of the SWC file and also makes debugging information
available to users.
To include the SWD file in your SWC file:
1.
Open your FLA file.
2.
In the Flash environment, select File > Publish Settings.
The Publish Settings dialog box appears.
3.
Select the Debugging Permitted check box.
4.
Click OK.
5.
Save the FLA file.
6.
Export the SWC file as described in “Creating SWC files” on page 18.
Flash includes the SWD file with the other files in your SWC file.