MACROMEDIA FLEX - DEVELOPING COMPONENTS AND THEMES Manual page 47

Developing flex components and themes in flash authoring
Table of Contents

Advertisement

Simple example of a class file
The following is a simple example of a class file called MyComponent.as. If you were creating this
component, you would link this file to the component in the Flash IDE.
This example contains a minimal set of imports, methods, and declarations for a component that
inherits from the UIObject class.
//Import packages.
import mx.core.UIObject;
//Declare the class and extend from the parent class.
class myPackage.MyComponent extends UIObject {
// Identify the symbol name that this class is bound to.
static var symbolName:String = "myPackage.MyComponent";
// Identify the fully qualified package name of the symbol owner.
static var symbolOwner:Object = Object(myPackage.MyComponent);
// Provide the className variable.
var className:String = "MyComponent";
// Define an empty constructor.
function MyComponent() {
}
// Override the init method, and call the parent's init method.
function init(Void):Void {
super.init();
// Call invalidate() to display graphics.
invalidate();
}
}
General process for writing a class file
Use the following general process when you write a component's ActionScript class file.
Depending on the type of component that you create, whether you override any of the superclass's
methods is optional. For the simplest form of component, you are not required to implement any
of these methods.
To write the ActionScript file for a component:
Select and extend a parent class.
1.
Define the
2.
symbolName
Write an empty class constructor.
3.
Specify properties that can be set using an MXML tag property (clip parameters).
4.
Implement the
5.
Implement the
6.
,
symbolOwner
constructObject2()
method.
init()
, and
properties.
className
method.
Writing the component's ActionScript code
47

Advertisement

Table of Contents
loading
Need help?

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

This manual is also suitable for:

Flex

Table of Contents