238 Classes
A sample file on your hard disk demonstrates how to create a dynamic menu with XML data
and a custom class file. The sample calls the ActionScript
XmlMenu() constructor and passes it
two parameters: the path to the XML menu file and a reference to the current timeline. The
rest of the functionality resides in a custom class file, XmlMenu.as.
You can find the sample source file, xmlmenu.fla, in the Samples folder on your hard disk.
■ On Windows, browse to boot drive\Program Files\Macromedia\Flash 8\Samples and
Tutorials\Samples\ActionScript\XML_Menu.
■ On the Macintosh, browse to Macintosh HD/Applications/Macromedia Flash 8/Samples
and Tutorials/Samples/ActionScript/XML_Menu.
About working with custom classes in an
application
In “Writing custom class files” on page 235, you created a custom class file. In the following
sections, you use that class file in an application. At the minimum, the workflow for creating
classes involves the following steps:
1. Define a class in an external ActionScript class file. For information on defining and
writing a class file, see “Writing custom class files” on page 235.
2. Save the class file to a designated classpath directory (a location where Flash looks for
classes), or in the same directory as the application’s FLA file. For more information on
setting the classpath, see “About setting and modifying the classpath” on page 240. For a
comparison and more information on importing class files, see “About importing class
files” on page 239.
3. Create an instance of the class in another script, either in a FLA document or an external
script file or by creating a subclass based on the original class. For more information on
creating an instance of a class, see “Creating instances of classes in an example”
on page 278.
The following sections in this chapter contain code examples that you can use to become
familiar with creating classes in ActionScript 2.0. If you’re not familiar with ActionScript 2.0,
please read Chapter 4, “Data and Data Types,” on page 71 and Chapter 5, “Syntax and
Language Fundamentals,” on page 113.