User Guide

Creating the ActionScript class file 143
Creating the ActionScript class file
All component symbols are linked to an ActionScript 2.0 class file. (For information on
linking, see “Creating a component movie clip” on page 138.)
To edit ActionScript class files, you can use Flash, any text editor, or any Integrated
Development Environment (IDE).
The external ActionScript class extends another class (whether the class is a version 2
component, a version 2 base class, or the ActionScript MovieClip class). You should extend
the class that creates the functionality that is most similar to the component you want to
create. You can inherit from (extend) only one class. ActionScript 2.0 does not allow multiple
inheritance.
Simple example of a component 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 movie clip in Flash.
This example contains a minimal set of imports, methods, and declarations for a component,
MyComponent, that inherits from the UIComponent class. The MyComponents.as file is
saved in the myPackage folder.
[Event("eventName")]
// 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() {
}
// Call the parent’s init() method.
// Hide the bounding box--it’s used
// only during authoring.