To create the Orange Circle:
Set up the Flash environment by adding the Flex components and class files. For more
1.
information, see
In Flash, create a new FLA file.
2.
Edit the FLA file's local classpath settings to include the following two classpath entries:
3.
$(LocalData)/Flex Classes
. (the dot)
For more information, see
Draw an orange circle on the Flash Stage and save the FLA file as orangecircle.fla.
4.
Create a file in a text editor and add the following code to it:
5.
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.
}
}
Save the text file as orangecircle.as in the myPackage subdirectory, below the directory in which
6.
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
Return to the Flash environment. Right-click the circle on the Stage, and select Convert to
7.
Symbol.
In the Convert to Symbol dialog box, set the Name field to orangecircle.
8.
Enter myPackage.orangecircle in the AS 2.0 Class and Identifier text boxes.
9.
Click OK.
10.
Flash adds the orange circle symbol to the Library.
Convert the symbol to a component by right-clicking the symbol in the Flash Library and
11.
selecting Component Definition.
In the Component Definition dialog box, set the AS2.0 Class field to myPackage.orangecircle.
12.
26
Chapter 2: Creating Basic Components in Flash MX 2004
"Adding Flex classes and components to the Flash IDE" on page
"Changing the Flash classpath" on page
8.
10.
Need help?
Do you have a question about the FLEX - DEVELOPING COMPONENTS AND THEMES and is the answer not in the manual?
Questions and answers