EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Page 596

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
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.
Theyre 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.
NOTE
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.

Table of Contents

Related product manuals