User Guide

146 Creating Components
Importing classes
You can import class files so that you dont have to write fully qualified class names
throughout your code. This can make code more concise and easier to read. To import a class,
use the
import statement at the top of the class file, as in the following:
import mx.core.UIObject;
import mx.core.ScrollView;
import mx.core.ext.UIObjectExtensions;
class MyComponent extends UIComponent{
You can also use the wildcard character (*) to import all the classes in a given package. For
example, the following statement imports all classes in the
mx.core package:
import mx.core.*;
If an imported class is not used in a script, the class is not included in the resulting SWF files
bytecode. As a result, importing an entire package with a wildcard does not create an
unnecessarily large SWF file.
Defining the class and its superclass
A component class file is defined like any class file. Use the class keyword to indicate the
class name. The class name must also be the name of the class file. Use the
extends keyword
to indicate the superclass. For more information, see Chapter 7, “Writing custom class files,
in Learning ActionScript 2.0 in Flash.
class MyComponentName extends UIComponent{
}