MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual page 267

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

6.
Save the ClassA.as ActionScript document.
7.
Select File > New and then select ActionScript File, and then click OK.
8.
Select File > Save As, name the new file ClassB.as, and save it in the same directory as
ClassA.as created in an earlier step.
9.
Type the following code into the Script window:
class com.macromedia.utils.ClassB {
}
The previous code creates a new class named ClassB in the com.macromedia.utils
package.
10.
Save your changes to both the ClassA.as and ClassB.as class files.
The class files you use in a FLA file import into a SWF file when you compile it. The code
you write in a class file should have a certain methodology and ordering, which are discussed
in the following sections.
If you are creating multiple custom classes, use packages to organize your class files. A package
is a directory that contains one or more class files and resides in a designated classpath
directory. A class name must be fully qualified within the file in which it is declared—that is,
it must reflect the directory (package) in which it is stored. For more information on
classpaths, see
"About setting and modifying the classpath" on page
For example, a class named
directory. The class declaration in the YourClass.as file looks like this:
macromedia/docs
class com.macromedia.docs.YourClass {
// your class
}
You write the class declaration that reflects the package directory in the following
section,
"Example: Writing custom classes" on page
For this reason, it's good practice to plan your package structure before you begin creating
classes. Otherwise, if you decide to move class files after you create them, you will have to
modify the class declaration statements to reflect their new location.
To package your class files:
1.
Decide on the package name you'd like to use.
Package names should be intuitive and easily identifiable by fellow developers. Remember
that the package name also matches a specific directory structure. For example, any classes
in the
com.macromedia.utils
folder on your hard drive.
com.macromedia.docs.YourClass
package needs to be placed in a com/macromedia/utils
240.
is stored in the
263.
Example: Writing custom classes
com/
267

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash 8

Table of Contents