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

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

Creating and packaging your class files
In this section, you create, name, and package your class files for this example
Writing custom classes" on page
complete (yet simple) class files. For detailed information on packages, see
on page
228,
"A comparison of classes and packages" on page
packages" on page
230.
When you create a class file, decide where you want to store the file. In the following steps,
you'll save the class file and the application FLA file that uses the class file in the same
directory for simplicity. However, if you want to check syntax, you also need to tell Flash how
it can find the file. Typically, when you create an application, you add the directory in which
you store your application and class files to the Flash classpath. For information about
classpaths, see
"About setting and modifying the classpath" on page
Class files are also called ActionScript (AS) files. You create AS files in the Flash authoring
tool or by using an external editor. Several external editors, such as Macromedia
Dreamweaver and Macromedia Flex Builder, can create AS files.
The name of a class (ClassA) must exactly match the name of the AS file that contains it
(ClassA.as). This is very important; if these two names don't match exactly, including
capitalization, the class won't compile.
To create a class file and class declaration:
1.
Select File > New and then select Flash Document to create a new FLA document, and then
click OK.
2.
Select File > Save As, name the new file package_test.fla, and save the Flash document to
the current directory.
You'll add content to this Flash document in a future step.
3.
Select File > New and then select ActionScript File, and then click OK.
4.
Select File > Save As and create a new subdirectory named com, and then do the following:
a.
In the com subdirectory, create a new subdirectory named macromedia.
b.
in the macromedia subdirectory, create an new subdirectory named utils.
c.
Save the current ActionScript document in the utils directory and name the file
ClassA.as.
5.
Type the following code into the Script window:
class com.macromedia.utils.ClassA {
}
The preceding code creates a new class named ClassA in the com.macromedia.utils
package.
266
Classes
263). The following sections show you how to write
("Example:
"About packages"
229, and
"Working with
240.

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?

Questions and answers

This manual is also suitable for:

Flash 8

Table of Contents