User Guide
Creating the ActionScript class file 933
Importing classes
You can import class files so that you don’t 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 file’s
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 10, “Creating Custom Classes with
ActionScript 2.0,” in Using ActionScript in Flash.
class MyComponentName extends UIComponent{
}
Identifying the class, symbol, and owner names
To help Flash find the proper ActionScript classes and packages and to preserve the component’s
naming, you must set the
symbolName, symbolOwner, and className variables in your
component’s ActionScript class file.
The
symbolOwner variable is an Object reference that refers to a symbol. If the component is its
own
symbolOwner or is the symbolOwner has been imported, it does not have to be fully
qualified.