596
Working with Images, Sound, and Video
6.
Add the following code to the Actions panel:
var my_pb:mx.controls.ProgressBar;
my_pb.mode = "manual";
this.createEmptyMovieClip("img_mc", 999);
var my_mcl:MovieClipLoader = new MovieClipLoader();
var mclListener:Object = new Object();
mclListener.onLoadStart = function(target_mc:MovieClip):Void {
my_pb.label = "loading: " + target_mc._name;
};
mclListener.onLoadProgress = function(target_mc:MovieClip,
numBytesLoaded:Number, numBytesTotal:Number):Void {
var pctLoaded:Number = Math.ceil(100 * (numBytesLoaded /
numBytesTotal));
my_pb.setProgress(numBytesLoaded, numBytesTotal);
};
my_mcl.addListener(mclListener);
my_mcl.loadClip("http://www.helpexamples.com/flash/images/image1.jpg",
img_mc);
7.
Test the document by selecting Control > Test Movie.
The image loads into the movie
img_mc
clip.
8.
Select File > Publish > Formats, and make sure the SWF and HTML options are selected.
9.
Click Publish and find the HTML and SWF files on your hard disk.
They’re in the same folder as progress.fla that you saved in step 1.
10.
Double-click the HTML document to open it in a browser and see the progress
bar animate.
For related information, see
“About loading SWF files and the root timeline” on page 597
.
For more information on the MovieClipLoader class, see
MovieClipLoader
in the
ActionScript 2.0 Language Reference
. For information on creating a progress bar animation, see
“Creating a progress animation for loading SWF and image files” on page 625
.
NO
T
E
When you load files in the test environment, make sure you load an uncached file
from the Internet and not a local file if you want to see the progress bar work. A local
file loads too quickly to see the progress. Alternatively, upload your SWF file and test
your document on a server.
Summary of Contents for FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Page 1: ...Learning ActionScript 2 0 in Flash...
Page 8: ...8 Contents...
Page 18: ...18 Introduction...
Page 30: ...30 What s New in Flash 8 ActionScript...
Page 66: ...66 Writing and Editing ActionScript 2 0...
Page 328: ...328 Interfaces...
Page 350: ...350 Handling Events...
Page 590: ...590 Creating Interaction with ActionScript...
Page 710: ...710 Understanding Security...
Page 730: ...730 Debugging Applications...
Page 780: ...780 Deprecated Flash 4 operators...
Page 830: ...830 Index...