User Guide

Table Of Contents
26 Chapter 2: Creating Basic Components in Flash MX 2004
To create the Orange Circle:
1.
Set up the Flash environment by adding the Flex components and class files. For more
information, see Adding Flex classes and components to the Flash IDE” on page 8.
2.
In Flash, create a new FLA file.
3.
Edit the FLA file’s local classpath settings to include the following two classpath entries:
$(LocalData)/Flex Classes
. (the dot)
For more information, see “Changing the Flash classpath” on page 10.
4.
Draw an orange circle on the Flash Stage and save the FLA file as orangecircle.fla.
5.
Create a file in a text editor and add the following code to it:
class myPackage.orangecircle extends mx.core.UIObject {
static var symbolName:String="myPackage.orangecircle";
static var symbolOwner:Object = myPackage.orangecircle;
var className:String="orangecircle";
function orangecircle() { // Empty constructor.
}
function init() {
super.init();
invalidate(); // Required call so that Flex draws the component.
}
}
6.
Save the text file as orangecircle.as in the myPackage subdirectory, below the directory in which
the FLA file is stored. This should be a directory that is not in the web application’s directory
structure, since these are source files for your eventual component. Furthermore, it cannot be
the same directory into which you deploy the SWC file and the MXML file.
The files you are using now should be in the following locations:
../orangecircle.fla
../myPackage/orangecircle.as
7.
Return to the Flash environment. Right-click the circle on the Stage, and select Convert to
Symbol.
8.
In the Convert to Symbol dialog box, set the Name field to orangecircle.
9.
Enter myPackage.orangecircle in the AS 2.0 Class and Identifier text boxes.
10.
Click OK.
Flash adds the orange circle symbol to the Library.
11.
Convert the symbol to a component by right-clicking the symbol in the Flash Library and
selecting Component Definition.
12.
In the Component Definition dialog box, set the AS2.0 Class field to myPackage.orangecircle.