Flash Player 6.
my_mc.onLoad = function() {
// your statements here
}
None.
Nothing.
Event handler; invoked when the movie clip is instantiated and appears in the Timeline. You must define a function that executes when the event handler is invoked. You can define the function on the Timeline or in a class file that extends the MovieClip class or is linked to a symbol in the library. For more information, see "Assigning a class to a movie clip symbol" in Using ActionScript in Flash.
This handler can be used only with movie clips for which you have a symbol in the library that is associated with a class. If you want an event handler to be invoked when a specific movie clip loads, for example when you use MovieClip.loadMovie() to load a SWF file dynamically, you must use onClipEvent(load) instead of this handler. The latter handler is invoked when any movie clip loads.
The following example illustrates one way to use MovieClip.onLoad() with setInterval() to check that a file has loaded into a movie clip that's created at runtime:
this.createEmptyMovieClip("tester_mc", 1);
tester_mc.loadMovie("http://www.yourserver.com/your_movie.swf");
function checkLoaded(target_mc:MovieClip) {
var pctLoaded:Number = target_mc.getBytesLoaded()/target_mc.getBytesTotal()*100;
if (!isNaN(pctLoaded) && (pctLoaded>0)) {
target_mc.onLoad = doOnLoad;
trace("clearing interval");
clearInterval(myInterval);
}
}
var myInterval:Number = setInterval(checkLoaded, 100, tester_mc);
function doOnLoad() {
trace("movie loaded");
}
The following example displays the equivalent of the previous ActionScript example:
this.createEmptyMovieClip("tester_mc", 1);
var mclListener:Object = new Object();
mclListener.onLoadInit = function(target_mc:MovieClip) {
trace("movie loaded");
};
var image_mcl:MovieClipLoader = new MovieClipLoader();
image_mcl.addListener(mclListener);
image_mcl.loadClip("http://www.yourserver.com/your_movie.swf", tester_mc);
onClipEvent(), MovieClipLoader class
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/00001534.html
Comments
recoveredfromflashMX2004 said on Aug 4, 2004 at 3:28 PM : webweber@bluewin.ch said on Nov 5, 2004 at 1:23 AM : No screen name said on Apr 26, 2005 at 4:07 PM :