
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
138
|
Chapter 5: Authoring an ActionScript 2.0 Class
1. Select frame 1 of the scripts layer.
2. In the Actions panel, cut (delete using Ctrl-X or Cmd-X) the following code from
frame 1:
var viewer:ImageViewer = new ImageViewer(this, 1);
viewer.loadImage("picture.jpg");
3. With frame 15 of the scripts layer selected, paste (using Ctrl-V or Cmd-V) the
code you deleted in Step 2 into the Actions panel.
Finally, we’ll add a loading message that displays while the ImageViewer class loads:
1. With frame 1 of the scripts layer selected, enter the following code into the
Actions panel:
this.createTextField("loadmsg_txt", 0, 200, 200, 0, 0);
loadmsg_txt.autoSize = true;
loadmsg_txt.text = "Loading...Please wait.";
2. With frame 15 of the scripts layer selected, enter the following code at the end of
the Actions panel (after the code entered in Step 2 of the previous procedure):
loadmsg_txt.removeTextField( );
That’s it! Test your movie using Control ➝ Test Movie. Once in Test Movie mode,
you can watch a simulated download of your movie by enabling the Bandwidth Pro-
filer (View
➝ Bandwidth Profiler) and then choosing View ➝ Simulate Download.
Because our class is so small, you may have to select a very slow download speed to
see the preloading message. To change the download speed, choose View
➝ Down- ...