03.05.2013 Views

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

This h<strong>and</strong>ler can be used only with movie clips for which you have a symbol in the library<br />

that is associated with a class. If you want an event h<strong>and</strong>ler to be invoked when a specific<br />

movie clip loads, for example when you use MovieClip.loadMovie() to load a SWF file<br />

dynamically, you must use onClipEvent(load) or the MovieClipLoader class instead of this<br />

h<strong>and</strong>ler. Unlike MovieClip.onLoad, the other h<strong>and</strong>lers are invoked when any movie clip<br />

loads.<br />

Example<br />

This example shows you how to use the onLoad event h<strong>and</strong>ler in an ActionScript 2.0 class<br />

definition that extends the MovieClip class. First, create a class file named Oval.as <strong>and</strong> define<br />

a class method named onLoad() <strong>and</strong> make sure that the class file is placed in the proper class<br />

path:<br />

// contents of Oval.as<br />

class Oval extends MovieClip{<br />

public function onLoad () {<br />

trace ("onLoad called");<br />

}<br />

}<br />

Second, create a movie clip symbol in your library <strong>and</strong> name it Oval. Context-click (usually<br />

right-click) on the symbol in the Library panel <strong>and</strong> select Linkage... from the pop-up menu.<br />

Click on "Export for ActionScript" <strong>and</strong> fill in the "Identifier" <strong>and</strong> "ActionScript 2.0 Class"<br />

fields with the word "Oval" (no quotes). Leave "Export in First Frame" checked <strong>and</strong> click<br />

OK.<br />

Third, go to the first frame of your file <strong>and</strong> enter the following code in the Actions Panel:<br />

var myOval:Oval = Oval(attachMovie("Oval","Oval_1",1));<br />

Finally, do a test movie, <strong>and</strong> you should see the output text "onLoad called".<br />

See also<br />

loadMovie (MovieClip.loadMovie method), onClipEvent h<strong>and</strong>ler, MovieClipLoader<br />

onMouseDown (MovieClip.onMouseDown h<strong>and</strong>ler)<br />

onMouseDown = function() {}<br />

Invoked when the mouse button is pressed. You must define a function that executes when<br />

the event h<strong>and</strong>ler is invoked. You can define the function on the Timeline or in a class file that<br />

extends the MovieClip class or is linked to a symbol in the library.<br />

Note: This event h<strong>and</strong>ler is supported in Flash Lite only if System.capabilities.hasMouse<br />

is true or System.capabilities.hasStylus is true.<br />

456 ActionScript classes

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!