Name
Call( ) Global Function — execute the script of a remote frame
Availability
Flash 4; deprecated in Flash 5
Synopsis
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 any value). In Flash 5, the function
statement is preferred.
Note that in Flash 5, 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 tellTarget( )
function. The
following example executes the script on frame 10 of the
box
clip:
tellTarget ("box") { call(10); }
See Also
Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.