EasyManua.ls Logo

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT - Page 548

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT
816 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...
548 Chapter 12: ActionScript Dictionary
Example
The following example illustrates the use of many of the MovieClipLoader methods and listeners.
// first set of listeners
var my_mcl = new MovieClipLoader();
myListener = new Object();
myListener.onLoadStart = function (target_mc)
{
myTrace ("*********First my_mcl instance*********");
myTrace ("Your load has begun on movie clip . = " + target_mc);
var loadProgress = my_mcl.getProgress(target_mc);
myTrace(loadProgress.bytesLoaded + " = bytes loaded at start");
myTrace(loadProgress.bytesTotal + " = bytes total at start");
}
myListener.onLoadProgress = function (target_mc, loadedBytes, totalBytes)
{
myTrace ("*********First my_mcl instance Progress*********");
myTrace ("onLoadProgress() called back on movie clip " + target_mc);
myTrace(loadedBytes + " = bytes loaded at progress callback " );
myTrace(totalBytes + " = bytes total at progress callback \n");
}
myListener.onLoadComplete = function (target_mc)
{
myTrace ("*********First my_mcl instance*********");
myTrace ("Your load is done on movie clip = " + target_mc);
var loadProgress = my_mcl.getProgress(target_mc);
myTrace(loadProgress.bytesLoaded + " = bytes loaded at end" );
myTrace(loadProgress.bytesTotal + " = bytes total at end=");
}
myListener.onLoadInit = function (target_mc)
{
myTrace ("*********First my_mcl instance*********");
myTrace ("Movie clip = " + target_mc + " is now initialized");
// you can now do any setup required, for example:
target_mc._width = 100;
target_mc._width = 100;
}
myListener.onLoadError = function (target_mc, errorCode)
{
myTrace ("*********First my_mcl instance*********");
myTrace ("ERROR CODE = " + errorCode);
myTrace ("Your load failed on movie clip = " + target_mc + "\n");
}
my_mcl.addListener(myListener);
//Now load the files into their targets.
// loads into movie clips - strings used as target
my_mcl.loadClip("http://www.somedomain.somewhere.com/
someFile.swf","_root.myMC");
my_mcl.loadClip("http://www.somedomain.somewhere.com/someOtherFile.swf",
"_level0.myMC2");
//failed load
my_mcl.loadClip("http://www.somedomain.somewhere.com/someFile.jpg",
_root.myMC5);
// loads into movie clips - movie clip instances used as target.
my_mcl.loadClip("http://www.somedomain.somewhere.com/someOtherFile.jpg",
_level0.myMC3);
// loads into _level1
my_mcl.loadClip("file:///C:/media/images/somePicture.jpg", 1);

Table of Contents

Related product manuals