As mentioned previously, every actionscript class contains its own defined set of properties (attributes of the class, like the MovieClip class's _x and _currentframe properties) and methods (functions, like the MovieClip class's gotoAndStop method). In addition to the built-in classes like Math, Date and Sound, which we'll look at in this section, you can also write your own classes. Because I use some of these in the following pages, I thought a little overview here would be in order.
First, a note about the built-in classes: in Flash MX 2004 all predefined classes are saved in a directory set up when Flash is installed. On my PC, that directory is Program Files\Macromedia\Flash MX 2004\en\First Run\Classes. The built-in classes in Flash 8 are saved in a directory with the same path, except Flash 8 is substituted for Flash MX 2004.
Now, about your own classes (or others you download): in ActionScript 2 (the version of ActionScript introduced in Flash MX 2004), you can define your own class by putting the code which defines the class in a separate .as (actionscript) file with the name of your class. A file named ScreenManager.as would contain code to define the ScreenManager class, for example.
Class files can either be saved in the same directory as the fla which uses them, or in a directory specifically set up to hold class files (especially useful if you use class files from multiple sources). If you create a separate directory to hold all of your own defined classes, you can tell Flash where to find it by choosing Edit, Preferences, selecting the Actionscript tab, clicking Actionscript 2.0 Settings, and adding the directory path to the classpath list. On my PC, for example, user-defined classes are stored in c:/AS2Classes, and I have the classpath information set up to look for a class in the default Flash class directory first, then the current directory (where the fla that's using the class is), and then my AS2Classes directory, as shown:

Then in the AS2Classes directory, I have folders set up for every domain I have downloaded classes from (eg, AS2Classes/org/dembicki, for classes from www.dembicki.org) or for which I have defined classes (eg, AS2Classes/com/flashcreations, for classes I use at this site). This insures that each class can be uniquely identified even if I get two classes of the same name from different sources. Each of those folders may contain further subdividing folders for classes providing different types of functionality. For example, I have a utils folder under com/flashcreations, in which I put classes that extend the builtin Math and String classes.
In the following pages, I'll give some examples of using the built-in Flash classes and introduce a few extra classes that provide extensions to Flash's built-in functionality.
Generally speaking, a class file contains
You'll see examples of class files in the pages of this section, so I won't go into more detail here.
In order to include any classes that are not built into Flash in your movies, you need to put an import statement in the class file or frame that is using the class. Eg, if the class file MathExtra.as is in the same directory as the fla that uses it:
import MathExtra;or, if you have class files saved in a central class directory, with subdirectories for different source domains:
import com.flashcreations.utils.MathExtra;Then all the properties and methods of the class become available for your program to use.
Discussed on this page:
ActionScript 2 classes, where to store, path, class structure, import
Other Resources
The ultimate reference book for ActionScript 2 Classes and using them to write object-oriented applications is Colin Moock's