Import Statement - MACROMEDIA FLASHLITE2 ACTIONSCRIPT-LANGUAGE Reference

Actionscript language reference
Table of Contents

Advertisement

import statement

import className import packageName.*
Note: To use this keyword, you must specify ActionScript 2.0 and Flash Player 6 or later in
the Flash tab of your FLA file's Publish Settings dialog box. This statement is supported in the
Actions panel as well as in external class files.
Lets you access classes without specifying their fully qualified names. For example, if you want
to use a custom class macr.util.users.UserClass in a script, you must refer to it by its fully
qualified name or import it; if you import it, you can refer to it by the class name:
// before importing
var myUser:macr.util.users.UserClass = new macr.util.users.UserClass();
// after importing
import macr.util.users.UserClass;
var myUser:UserClass = new UserClass();
If there are several class files in the package (
) that
working_directory/macr/utils/users
you want to access, you can import them all in a single statement, as shown in the following
example:
import macr.util.users.*;
You must issue the
statement before you try to access the imported class without fully
import
specifying its name.
If you import a class but don't use it in your script, the class isn't exported as part of the SWF
file. This means you can import large packages without being concerned about the size of the
SWF file; the bytecode associated with a class is included in a SWF file only if that class is
actually used.
The
statement applies only to the current script (frame or object) in which it's called.
import
For example, suppose on Frame 1 of a Flash document you import all the classes in the
macr.util package. On that frame, you can reference classes in that package by their simple
names:
// On Frame 1 of a FLA:
import macr.util.*;
var myFoo:foo = new foo();
On another frame script, however, you would need to reference classes in that package by
their fully qualified names (
) or add an
var myFoo:foo = new macr.util.foo();
import
statement to the other frame that imports the classes in that package.
Availability: ActionScript 2.0; Flash Lite 2.0
Parameters
- The fully qualified name of a class you have defined in an external
className:String
class file.
Statements
203

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flash lite 2

Table of Contents