EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Example: Using Custom Class Files in Flash

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
276 Classes
You might also add the block, single-line, or trailing comments within the classs code. For
information on writing good comments within your code, see Writing good comments
on page 743. For general information about comments, see “Single-line comments
on page 132, “Multiline comments” on page 133, and “Trailing comments” on page 134.
To learn how to use these custom class files in a SWF file, see “Example: Using custom class
files in Flash” on page 276.
Example: Using custom class files
in Flash
This example uses class files that are written in the example called “Example: Writing custom
classes” on page 263, or you can download them from www.helpexamples.com/flash/learnas/
classes/. If you completed “Example: Writing custom classes” on page 263, locate ClassA.as
and ClassB.as on your hard disk.
Since the package name of the ClassA class file is
com.macromedia.utils.ClassA, you’ll
need to make sure that you save the class files in the proper directory structure. Create a
subfolder named com in the current directory. Within the com folder, add a new folder
named macromedia. Add a third, and final, subdirectory within the macromedia folder
named utils. Save both the ClassA.as and ClassB.as class files within this utils folder. Now you
are ready to proceed with this example.
You can use the custom classes written in “Example: Writing custom classes” on page 263
with a FLA file. In this example, you use the custom classes to create a small application in
Flash. Your classes compile into the SWF file when you publish the document, and then
everything works together. In the following exercises, you learn how classpaths work, how to
use class files in your application, as well as how to import classes and packages.
To continue this example, proceed to “Importing classes and packages” on page 276.
Importing classes and packages
To reference a class in another script, you must prefix the class name with the classs package
name. The combination of a classs name and its package path is the classs fully qualified class
name. If a class resides in a top-level classpath directory—not in a subdirectory in the
classpath directory—then its class name is also its fully qualified class name.

Table of Contents

Related product manuals