MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual page 594

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

For more information about loading external SWF and image files, see
files and the root timeline" on page
To preload SWF and JPEG files into movie clip instances, you can use the MovieClipLoader
class. This class provides an event listener mechanism to give notification about the status of
file downloads into movie clips. To use a MovieClipLoader object to preload SWF and JPEG
files, you must complete the following:
Create a new MovieClipLoader object
track the downloading progress of multiple files or create a separate object for each file's
progress. Create a new movie clip, load your contents into it, then create the
MovieClipLoader object as shown in the following code:
this.createEmptyMovieClip("img_mc", 999);
var my_mcl:MovieClipLoader = new MovieClipLoader();
Create a listener object and create event handlers
ActionScript object, such as a generic Object object, a movie clip, or a custom component.
The following example creates a generic listener object named
itself
,
onLoadError
onLoadStart
// Create listener object:
var mclListener:Object = new Object();
mclListener.onLoadError = function(target_mc:MovieClip, errorCode:String,
status:Number) {
trace("Error loading image: " + errorCode + " [" + status + "]");
};
mclListener.onLoadStart = function(target_mc:MovieClip):Void {
trace("onLoadStart: " + target_mc);
};
mclListener.onLoadProgress = function(target_mc:MovieClip,
numBytesLoaded:Number, numBytesTotal:Number):Void {
var numPercentLoaded:Number = numBytesLoaded / numBytesTotal * 100;
trace("onLoadProgress: " + target_mc + " is " + numPercentLoaded + "%
loaded");
};
mclListener.onLoadComplete = function(target_mc:MovieClip,
status:Number):Void {
trace("onLoadComplete: " + target_mc);
};
Flash Player 8 allows you to check the HTTP status of a MovieClipLoader download
within the onLoadComplete and onLoadError event listeners. This ability allows you to
check why the file was unable to download—whether it was a server error, or the file was
unable to be found, and so on.
594
Working with Images, Sound, and Video
597.
You can use a single MovieClipLoader object to
,
, and
onLoadProgress
"About loading SWF
The listener object can be any
loadListener
onLoadComplete
and defines for
functions:

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Flash 8

Table of Contents