
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
134
|
Chapter 5: Authoring an ActionScript 2.0 Class
Using ImageViewer in a Movie
Now that our ImageViewer class is ready for testing, let’s see how to actually use it in
a Flash movie! We’ll start by obtaining an image file to load, as follows:
1. Find a (nonprogressive format) JPEG image on your system. If you work in an
office, ensure that the content of the JPEG you choose is appropriate for the
office environment. If you can’t find a JPEG image, download one with the com-
pleted ImageViewer example posted at http://moock.org/eas2/examples.
2. Name the JPEG image picture.jpg and place it in the same folder as the Image-
Viewer.as file you created earlier.
Next we’ll create a Flash document (.fla file) from which we’ll publish a Flash
movie (.swf file) containing an instance of our ImageViewer class. For now, we’ll
place the .fla file, .as file, .swf file, and .jpg file all in the same folder, making it easy
for each file to access the other files.
When a .fla file and a class file (i.e., an .as file with a class definition)
reside in the same directory, code in the .fla file can refer to the class in
the .as file directly by name. Hence, the easiest way to use an Action-
Script 2.0 class is to place its .as file in the same folder as the .fla file
that uses it. The class will automatically ...