call( ) Global Function

ActionScript for Flash MX: The Definitive Guide, 2nd Edition
By Colin Moock
Chapter 18.  ActionScript Language Reference
call( ) Global Function Flash 4

execute the script of a remote frame
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:

tellTarget ("box") {   call(10); }

See Also

Chapter 9; Appendix C



    ActionScript for Flash MX. The Definitive Guide
    ActionScript for Flash MX: The Definitive Guide, Second Edition
    ISBN: 059600396X
    EAN: 2147483647
    Year: 2002
    Pages: 780
    Authors: Colin Moock

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net