View comments | RSS feed

MovieClipLoader class

Availability

Flash Player 7.

Description

This class lets you implement listener callbacks that provide status information while SWF or JPEG files are being loaded (downloaded) into movie clips. To use MovieClipLoader features, use MovieClipLoader.loadClip() instead of loadMovie() or MovieClip.loadMovie() to load SWF files.

After you issue the MovieClipLoader.loadClip() command, the following events take place in the order listed:

After MovieClipLoader.onLoadInit has been invoked, you can set properties, use methods, and otherwise interact with the loaded movie.

If the file fails to load completely, the MovieClipLoader.onLoadError listener is invoked.

Method summary for the MovieClipLoader class

Method Description
MovieClipLoader.addListener()

Registers an object to receive notification when a MovieClipLoader event handler is invoked.

MovieClipLoader.getProgress()

Returns the number of bytes loaded and total number of bytes for a file that is being loaded using MovieClipLoader.loadClip().

MovieClipLoader.loadClip()

Loads a SWF or JPEG file into a movie clip in Flash Player while the original movie is playing.

MovieClipLoader.removeListener()

Deletes an object that was registered using MovieClipLoader.addListener().

MovieClipLoader.unloadClip()

Removes a movie clip that was loaded by means of MovieClipLoader.loadClip().

Listener summary for the MovieClipLoader class

Listener Description
MovieClipLoader.onLoadComplete

Invoked when a file loaded with MovieClipLoader.loadClip() has completely downloaded.

MovieClipLoader.onLoadError

Invoked when a file loaded with MovieClipLoader.loadClip() has failed to load.

MovieClipLoader.onLoadInit

Invoked when the actions on the first frame of the loaded clip have been executed.

MovieClipLoader.onLoadProgress

Invoked every time the loading content is written to disk during the loading process.

MovieClipLoader.onLoadStart

Invoked when a call to MovieClipLoader.loadClip() has successfully begun to download a file.

Constructor for the MovieClipLoader class

Availability

Flash Player 7.

Usage

new MovieClipLoader() : MovieClipLoader

Parameters

None.

Returns

A reference to a MovieClipLoader object.

Description

Constructor; creates a MovieClipLoader object that you can use to implement a number of listeners to respond to events while a SWF or JPEG file is downloading.

Example

See MovieClipLoader.loadClip().

See also

MovieClipLoader.addListener()

Comments


recoveredfromflashMX2004 said on Aug 4, 2004 at 3:33 PM :
gauravgoel said on May 11, 2004 at 9:40 PM :

This feature is great but I am yet not able to find the way how to use this MovieClipLoader class to load sound ? Can someone pls. tell about that?


No screen name said on Jun 14, 2004 at 6:32 AM :

I did a test, if the LoadComplete was called, the picture was still not show in the screen. And I tried to get the mc's properties, the _height was still 0.Just wonder what does it means "LoadComplete"? Is there anyway I can get the mc's properties like "_height" or "_width" after the picture TOTOALLY complete loaded into SCREEN?
Sample code as follows:

var pic_mc:MovieClip = _root.createEmptyMovieClip("tmp",1000);
var cube_mcl:MovieClipLoader = new MovieClipLoader;

myListener = new Object();
cube_mcl.addListener(myListener);

myListener.onLoadComplete = function(){
trace("sample.jpg completely loaded!!");
cube_mcl.removeListener(myListener);
trace(_root.pic_mc._height); //The trace output always "0".
}

cube_mcl.loadClip("Sample.jpg",pic_mc);


andreCassal said on Jun 17, 2004 at 7:03 PM :

use "onLoadInit" to get this info;


rg@mm said on Jul 2, 2004 at 10:43 AM :

It appears that updateAfterEvent() doesn't do anything during the progress callback, and timer events get very late during load, so progress bar animation becomes very jerky. Is there a "best practices" for displaying a progress bar? -- Trace() works fine, but I want to present feedback.


webweber@bluewin.ch said on Jul 13, 2004 at 12:50 AM :

This class seems to be a bit undecided wether it follows a event handler or a event listener model.

Obviously the event handler functions of a MovieClipLoader instance are automatically called when a event is broadcast. Thus this works fine:

var myMCL = new MovieClipLoader();

myMCL.onLoadInit = function(){
trace('completely loaded')
}

myMCL.loadClip('someMovie.swf', 10);

However, the documentation suggests to create a separate listener object, define the handlers on that object and add this listener via addListener();

Isn't that unnecessarily complicated?

The example above throws a compiler error when the MovieClipLoader instance is stricly typed:

var myMCL:MovieClipLoader = new MovieClipLoader();

I guess there is an intrinsic class missing somewhere.

Is there hope that this will be fixed in the next version?
Vrvy said on Oct 16, 2004 at 12:03 PM :
Just a little scheme I use... I find examples too complex for some occasional copy/pasting...

var loaderObj:MovieClipLoader = new MovieClipLoader();
loaderObj.addListener({
onLoadProgress: function() {
//*** do preloading things ***
},
onLoadInit: function() {
//*** do resizing ***
delete loaderObj;
}
});
loaderObj.loadClip( image-to-load, target-movie-clip );
roland212 said on May 2, 2005 at 2:44 AM :
What's the lifecycle/garbage collection rules for a MovieClipLoader?

It's not clear from the documentation when a MovieClipLoader goes out
of scope and is garbage collected.
Pascal323 said on Aug 12, 2005 at 12:55 PM :
It seems there is a few problems with the scope of things.

I have created a .swf movie which uses customized components and skins. The movie works just fine when I play it alone.

However, once I load movie A from movie B, the window contentpath of movie A cannot be found? Everything seems to be scoped to the movie B?

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/mx2004/main_7_2/00001574.html