
Capabilities Object
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Alphabetical Language Reference
|
479
call() Global Function
execute the script of a remote frame
Flash 4
call(frameLabel)
call(frameNumber)
Arguments
frameLabel A string representing the label of the frame whose script should be executed.
frameNumber
The number of the frame whose script should be executed.
Description
The call() function executes the script attached to the frame at frameLabel or frameNumber.
For example, the following code runs the script on frame 20 of the current timeline:
call(20);
In Flash 4, call() was used to create a crude kind of reusable subroutine (one that could not
accept parameters or return a value). As of Flash 5, the function statement is the preferred
way to define a function.
Note that in Flash 5 and later, when a script is executed remotely via call(), any variables
declared with the var keyword are considered local to that execution and expire after the
script completes. To create nonlocal variables in a remotely-executed script, omit the var
keyword:
var x = 10; // Local variable; dies after script completes
x = 10; // Timeline variable; persists after script completes
To invoke call() on frames outside the current timeline, use the deprecated tellTarget()
function. The following example executes the script on frame 10 of the
box clip: