Using The Call() Function To Create Functions - MACROMEDIA FLASH 8-LEARNING FLASH LITE 1.X ACTIONSCRIPT Manual

Learning flash lite 1.x actionscript
Table of Contents

Advertisement

Using the call() function to create
functions
You can't define or call custom functions in Flash Lite as you can in Flash Player 5 and later.
However, you can use the
arbitrary frame in the timeline. This technique lets you encapsulate commonly used code in a
single location, making it easier to maintain.
The
function takes a frame number or frame label as a parameter. For example, the
call()
following ActionScript calls the code located on the frame labeled
call("moveUp");
The
function operates synchronously; any ActionScript that follows a
call()
function call won't execute until all of the ActionScript on the specified frame finishes
executing.
To call ActionScript on another frame:
1.
In a new Flash document, insert a keyframe on Frame 10.
2.
With the new keyframe selected, open the Actions panel (Window > Actions), and type the
following code:
trace("Hello from frame 10");
3.
Select the keyframe on Frame 1, and in the Actions panel, type the following code:
stop();
call(10);
This code stops the playhead on Frame 1, and then calls the code on Frame 10.
4.
Test the application in the emulator and open the Output panel (Window > Output).
You should see "Hello from frame 10" displayed in the Output panel.
ActionScript function to execute code that resides on an
call()
moveUp

Using the call() function to create functions

:
call()
13

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-LEARNING FLASH LITE 1.X ACTIONSCRIPT and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash 8

Table of Contents