![]() ![]() ![]() | |
![]() | |
![]() | |
![]() |
Flash Player 7.
my_mcl
.loadMovie(
"url
",target
)
url
The absolute or relative URL of the SWF file or JPEG file to be loaded. A relative path must be relative to the SWF file at level 0. Absolute URLs must include the protocol reference, such as http:// or file:///. Filenames cannot include disk drive specifications.
target
The target path of a movie clip, or an integer specifying the level in Flash Player into which the movie will be loaded. The target movie clip will be replaced by the loaded movie or image.
Nothing.
Method; loads a SWF or JPEG file into a movie clip in Flash Player while the original movie is playing. Using this method lets you display several movies at once and switch between movies without loading another HTML document.
Using this method instead of loadMovie()
or MovieClip.loadMovie()
has a number of advantages:
MovieClipLoader.onLoadStart()
handler is invoked when loading begins.MovieClipLoader.onLoadError()
handler is invoked if the clip cannot be loaded.MovieClipLoader.onLoadProgress()
handler is invoked as the loading process progresses.MovieClipLoader.onLoadInit()
handler is invoked after the actions in the first frame of the clip have executed, so you can being manipulating the loaded clip.A movie or image loaded into a movie clip inherits the position, rotation, and scale properties of the movie clip. You can use the target path of the movie clip to target the loaded movie.
You can use this method to load one or more files into a single movie clip or level; MovieClipLoader listener objects are passed the loading target movie clip instance as a parameter. Alternately, you can create a different MovieClipLoader object for each file you load.
Use MovieClipLoader.unloadClip()
to remove movies or images loaded with this method or to cancel a load operation that is in progress.
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); //Second set of listeners var another_mcl = new MovieClipLoader(); myListener2 = new Object(); myListener2.onLoadStart = function (target_mc) { myTrace("*********Second my_mcl instance*********"); myTrace ("Your load has begun on movie clip22 . = " + target_mc); var loadProgress = my_mcl.getProgress(target_mc); myTrace(loadProgress.bytesLoaded + " = bytes loaded at start" ); myTrace(loadProgress.bytesTotal + " = bytes total at start"); } myListener2.onLoadComplete = function (target_mc) { myTrace ("*********Second 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" ); } myListener2.onLoadError = function (target_mc, errorCode) { myTrace ("*********Second my_mcl instance*********"); myTrace ("ERROR CODE = " + errorCode); myTrace ("Your load failed on movie clip = " + target_mc + "\n"); } another_mcl.addListener(myListener2); //Now load the files into their targets (using the second instance of MovieClipLoader) another_mcl.loadClip("http://www.somedomain.somewhere.com/yetAnotherFile.jpg", _root.myMC4); // Issue the following statements after the download is complete, // and after my_mcl.onLoadInit has been called. // my_mcl.removeListener(myListener) // my_mcl.removeListener(myListener2)
![]() | |
![]() | |
![]() | |
![]() ![]() ![]() |