![]() ![]() ![]() | |
![]() | |
![]() | |
![]() |
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.
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 the correct use of MovieClip.onLoad()
and onClipEvent(load)
.
// symbol_mc is a movie clip symbol in the library. // It is linked to the MovieClip class. // The following function is triggered for each instance of symbol_mc // as it is instantiated and appears on the Timeline. symbol_mc.onLoad = function() { trace("The movie clip is loaded"); } // dynamic_mc is a movie clip that is being loaded with MovieClip.loadMovie(). // This code attempts to call a function when the clip is loaded, // but it will not work, because the loaded SWF is not a symbol // in the library associated with the MovieClip class. function output() { trace("Will never be called."); } dynamic_mc.onLoad = output; dynamic_mc.loadMovie("replacement.swf"); // The following function is invoked for any movie clip that // appears on the Timeline, whether it is in the library or not. // Therefore, this function is invoked when symbol_mc is instantiated // and also when replacement.swf is loaded. OnClipEvent( load ) { trace("The movie clip is loaded"); }
![]() | |
![]() | |
![]() | |
![]() ![]() ![]() |