Movieclip.onload - MACROMEDIA FLASH MX 2004-ACTIONSCRIPT LANGUAGE Reference

Actionscript language reference
Table of Contents

Advertisement

MovieClip.onLoad

Availability
Flash Player 6.
Usage
my_mc.onLoad = function() {
// your statements here
}
Parameters
None.
Returns
Nothing.
Description
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
must use
onClipEvent(load)
movie clip loads.
Example
The following example illustrates one way to use
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");
}
MovieClip.loadMovie()
instead of this handler. The latter handler is invoked when any
MovieClip.onLoad()
to load a SWF file dynamically, you
with
setInterval()
MovieClip.onLoad
to
559

Advertisement

Table of Contents
loading
Need help?

Need help?

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

This manual is also suitable for:

Flash mx

Table of Contents