MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT Reference Manual page 199

Actionscript reference guide
Hide thumbs Also See for FLASH MX 2004 - ACTIONSCRIPT:
Table of Contents

Advertisement

Preloading SWF and JPEG files
To preload SWF and JPEG files into movie clip instances, you can use the
This class provides an event listener mechanism to give notification about the status of file
downloads into movie clips. Using a MovieClipLoader object to preload SWF and JPEG files
involves the following steps:
Create a new MovieClipLoader object
the download progress of multiple files, or create a separate object for each file's progress.
var loader: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.
For example, the following code creates a generic listener object named
defines for itself
// Create listener object:
var loadListener:Object = new Object();
loadListener.onLoadStart = function (loadTarget) {
trace("Loading into " + loadTarget + " has started.");
}
loadListener.onLoadProgress = function(loadTarget, bytesLoaded, bytesTotal) {
var percentLoaded = bytesLoaded/bytesTotal * 100;
trace("%" + percentLoaded + " into target " + loadTarget);
}
loadListener.onLoadComplete = function(loadTarget) {
trace("Load completed into: " + loadTarget);
}
Register the listener object with the MovieClipLoader object
to receive the loading events, you must register it with the MovieClipLoader object.
loader.addListener(loadListener);
Begin loading the file (JPEG or SWF) into a target clip
SWF file, you use the
loader.loadClip("scene_2.swf");
Note: You can use only MovieClipLoader methods to track the download progress of files loaded
with the
MovieClipLoader.loadClip()
MovieClip.loadMovie()
The following example uses the
display the download progress of a SWF file. (See "ProgressBar component" in Using
Components Help.)
,
onLoadStart
onLoadProgress
MovieClipLoader.loadClip()
method. You cannot use the
method.
setProgress()
You can use a single MovieClipLoader object to track
The listener object can be any
, and
onLoadComplete
To start the download of the JPEG or
method.
method of the ProgressBar component to
MovieClipLoader
, and
loadListener
functions.
In order for the listener object
function or
loadMovie()
Preloading external media
class.
199

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004 - ACTIONSCRIPT and is the answer not in the manual?

Questions and answers

Table of Contents