Importing Classes - MACROMEDIA FLASH MX 2004-USING ACTIONSCRIPT IN FLASH Use Manual

Using actionscript in flash
Hide thumbs Also See for FLASH MX 2004-USING ACTIONSCRIPT IN FLASH:
Table of Contents

Advertisement

Alternatively, double-click the path in the Classpath list, type the desired path, and
click OK.
To delete a directory from the classpath, select the path in the Classpath list and click the
Remove Selected Path (-) button.

Importing classes

To reference a class in another script, you must prefix the class name with the class's package path.
The combination of a class's name and its package path is the class's fully qualified class name. If a
class resides in a top-level classpath directory—not in a subdirectory in the classpath directory—
then its fully qualified class name is its class name.
To specify package paths, use dot (.) notation to separate package directory names. Package paths
are hierarchical, where each dot represents a nested directory. For example, suppose you create a
class named Data that resides in a com/xyzzycorporation/ package in your classpath. To create an
instance of that class, you could specify the fully qualified class name, as shown in the following
example:
var dataInstance = new com.xyzzycorporation.Data();
You can also use the fully qualified class name to type your variables, as shown in the following
example:
var dataInstance:com.xyzzycorporation.Data = new Data();
You can use the
abbreviated name rather than its fully qualified name. You can also use the wildcard character (*)
to import all the classes in a package.
For example, suppose you created a class named UserClass that's included in the package directory
path com/xyzzycorporation/util/users:
// In the file com/xyzzycorporation/util/users/UserClass.as
class com.xyzzycorporation.util.users.UserClass { ... }
Suppose that in another script, you imported that class using the
the following example:
import com.xyzzycorporation.util.users.UserClass;
Later, in the same script, you could reference that class by its abbreviated name, as shown in the
following example:
var myUser:UserClass = new UserClass();
You can use the wildcard character (*) to import all the classes in a given package. For example,
suppose you have a package named
ActionScript class files, Rosencrantz.as and Guildenstern.as. In another script, you could import
both classes in that package using the wildcard character, as shown in the following code:
import com.xyzzycorporation.util.*;
statement to import packages into a script, which lets you use a class's
import
com.xyzzycorporation.util
statement, as shown in
import
that contains two
Importing classes
271

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004-USING ACTIONSCRIPT IN FLASH and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Flash mx 2004 - actionscript

Table of Contents