5.1 Class Authoring Quick Start

 <  Day Day Up  >  

Before we jump into designing the ImageViewer class, let's take a brief, high-level look at the minimal steps required to author and use an ActionScript 2.0 class in Flash. Don't worry if some of the concepts in this overview are foreign to you ”we'll cover each of them in detail throughout the remainder of this chapter.

To create an ActionScript 2.0 class, follow these general steps:

  1. Create a new text file with the .as extension using any plain text editor or Flash MX Professional 2004's built-in editor. The .as file's name must match the class name exactly (case sensitivity matters).

  2. Add the class definition to the .as file. For example:

     class   NameOfClass   {   // Class body goes here } 

To use an ActionScript 2.0 class in a Flash movie, follow these general steps:

  1. Create a .fla file with any name, and place it in the same folder as the .as file from Step 1 in the preceding procedure.

  2. Optionally specify the class's export frame for the .fla file via File Publish Settings Flash ActionScript Version Settings Export Frame for Classes. This determines when the class loads and when it becomes available in the movie. The export frame is usually set to some frame after your movie's preloader.

  3. Use the class as desired throughout the .fla file, but after the export frame specified in Step 2 (if any).

  4. Export a .swf file using one of the following: File Publish, Control Test Movie, or File Export Export Movie.

The preceding steps apply nicely to small projects in which code reuse and distribution are not factors. For information on managing a group of classes across many applications, see Chapter 9 and Chapter 14.

Now let's get started building the ImageViewer class.

 <  Day Day Up  >  


Essential ActionScript 2.0
Essential ActionScript 2.0
ISBN: 0596006527
EAN: 2147483647
Year: 2004
Pages: 177
Authors: Colin Moock

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net