
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Flash 5–style onClipEvent( ) Order of Execution
|
237
Moral of the story: obviously, the location of the function declaration
can change, so it’s a little dangerous to use unqualified references
inside handlers at all. Qualify all nonlocal identifiers within handlers
with
this or some other explicit object reference.
Values of the this Keyword
In our study of ActionScript’s event handling tools, we’ve encountered the this key-
word several times. Within an event handler,
this normally refers to the object that
received notification of the event. However, Flash’s evolution through multiple event
systems has complicated the issue. Table 10-2 provides a guide to the values of the
this keyword in ActionScript’s various event handling mechanisms.
Flash 5–style onClipEvent( )
Order of Execution
Some movies have code dispersed across multiple timelines and on( ) and
onClipEvent( ) handlers. It’s not uncommon, therefore, for a single frame to require
the execution of many separate blocks of code—some in event handlers, some on
frames in clip timelines, and some on the main timelines of documents in the Player.
In these situations, the order in which the various bits of code execute can become
quite complex and can greatly affect a program’s behavior. We can prevent surprises
and guarantee that our ...