Understanding The Classpath - MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT Reference Manual

Actionscript reference guide
Hide thumbs Also See for FLASH MX 2004 - ACTIONSCRIPT:
Table of Contents

Advertisement

For example, the following code first checks if the object name
Movable interface before calling the
if(Movable(someObject) != null) {
someObject.moveUp();
}

Understanding the classpath

In order to use a class or interface that you've defined, Flash must be able to locate the external AS
files that contain the class or interface definition. The list of directories in which Flash searches for
class and interface definitions is called the classpath.
When you create an ActionScript class file, you need to save the file to one of the directories
specified in the classpath, or a subdirectory therein. (You can modify the classpath to include the
desired directory path; see
able to resolve, or locate, the class or interface specified in the script. Subdirectories that you create
within a classpath directory are called packages and let you organize your classes. (For more
information, see
Global and document-level classpaths
Flash has two classpath settings: a global classpath and a document-level classpath. The global
classpath applies to external AS and FLA files and is set in the Preferences dialog box (Edit >
Preferences). The document-level classpath applies only to FLA files and is set in the Publish
Settings dialog (File > Publish Settings) for a particular FLA.
By default, the global classpath contains two directory paths: a relative path that points to the
directory that contains the current document, and the Classes directory located in the user
configuration directory installed with Flash. The location of this directory is shown here:
Windows 2000 or Windows XP: C:\Documents and Settings\<user>\Local Settings\
Application Data\Macromedia\Flash MX2004\<language>\Configuration\
Windows 98: C:\Windows\Application Data\Macromedia\Flash MX 2004\
<language>\Configuration\
Macintosh OS X: Hard Drive/Users/Library/Application Support/Macromedia/
Flash MX 2004/<language>/Configuration/
The document-level classpath is empty by default.
How the compiler resolves class references
When Flash attempts to resolve class references in a FLA script, it first searches the document-
level classpath specified for that FLA. If the class is not found in that classpath, or if that classpath
is empty, Flash searches the global classpath. If the class is not found in the global classpath, a
compiler error occurs.
When Flash attempts to resolve class references in an AS script, it searches only the global
classpath directories, since AS files don't have an associated document class path.
moveUp()
"Modifying the classpath" on page
"Using packages" on page
someObject
method on the object.
170.) Otherwise, Flash won't be
171.)
Understanding the classpath
implements the
169

Advertisement

Table of Contents
loading
Need help?

Need help?

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

Subscribe to Our Youtube Channel

Table of Contents