
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Function Availability and Life Span
|
193
Function Availability
Custom program functions (the functions we create in our code) are directly accessi-
ble for invocation only from:
• Code attached to the timeline of the movie clip that bears the function declara-
tion
• Code in a Flash 5–style onClipEvent( ) handler on the movie clip that bears the
function declaration
• Code in a Flash 5–style on( ) event handler on a button on the timeline of the
movie clip that bears the function declaration
By “directly accessible,” we mean that the function can be invoked simply by name,
without reference to a movie clip or object, like this:
myFunction();
Functions are also indirectly accessible (i.e., remotely accessible), using dot syntax,
from any point in a movie. As when referring to variables remotely, we must include
the path to the movie clip that contains the function, such as:
myClip.myOtherClip.myFunction();
_parent.myFunction();
_root.myFunction();
So, suppose a clip instance named rectangle on the main timeline contains a func-
tion named area( ). We can invoke area( ) from anywhere in our movie, using an
absolute path to
rectangle, like this:
_root.rectangle.area();
To reference a function from a remote movie clip timeline, we follow the same rules
used when referring to remote variables, as