call( ) Global Function | Flash 4 |
execute the script of a remote frame |
A string representing the label of the frame whose script should be executed.
The number of the frame whose script should be executed.
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:
tellTarget ("box") { call(10); }