Onload (Movieclip.onload Handler) - MACROMEDIA FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE Reference

Flash lite 2.x actionscript language reference
Hide thumbs Also See for FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE:
Table of Contents

Advertisement

onLoad (MovieClip.onLoad handler)

onLoad = function() {}
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.
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
dynamically, you must use onClipEvent(load) or the MovieClipLoader class instead of this
handler. Unlike
MovieClip.onLoad
loads.
Availability: ActionScript 1.0; Flash Lite 2.0
Example
This example shows you how to use the
definition that extends the MovieClip class. First, create a class file named Oval.as and define
a class method named
path:
// contents of Oval.as
class Oval extends MovieClip{
public function onLoad () {
trace ("onLoad called");
}
}
Second, create a movie clip symbol in your library and name it Oval. Context-click (usually
right-click) on the symbol in the Library panel and select Linkage... from the pop-up menu.
Click on "Export for ActionScript" and fill in the "Identifier" and "ActionScript 2.0 Class"
fields with the word "Oval" (no quotes). Leave "Export in First Frame" checked and click
OK.
Third, go to the first frame of your file and enter the following code in the Actions Panel:
var myOval:Oval = Oval(attachMovie("Oval","Oval_1",1));
Finally, do a test movie, and you should see the output text "onLoad called".
See also
loadMovie (MovieClip.loadMovie method)
500
ActionScript classes
, the other handlers are invoked when any movie clip
onLoad
and make sure that the class file is placed in the proper class
onLoad()
MovieClip.loadMovie()
event handler in an ActionScript 2.0 class
,
onClipEvent handler
to load a SWF file
,
MovieClipLoader

Advertisement

Table of Contents
loading

Table of Contents