
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
124
Chapter 5
CHAPTER 5
Authoring an ActionScript 2.0 Class
In Chapter 4 we studied the general anatomy of ActionScript 2.0 classes. In this
chapter we’ll put that theory into practice by authoring a real-world ActionScript 2.0
class named ImageViewer. The ImageViewer class creates an on-screen rectangular
region for displaying a loaded JPEG image. We’ll cover designing and coding the
class itself, as well as using it in a Flash document.
The ImageViewer source files discussed in this chapter are available for download at
http://moock.org/eas2/examples.
Class Authoring Quick Start
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 ...