I heard and read some topics about the use of call() method to launch script in FlashLite applications, so I decided to give my simple example.
The call() method executes the script in the called frame without moving the playhead to that frame.
Create a movieclip in the library, drag it to the Timeline and give it an istance name of myMovie_mc . Click on it and in the movie clip timeline, create 3 frames with two different labels named : first_lbl and second_lbl. (leave the first frame blank)
Now write a simple script on each of two frames (it's enough to use a trace() command) and do not miss the stop() command in every frames.
To execute the script from your main timeline you can simple write this code on first frame or use a keylistener :
call("myMovie_mc:first_lbl");
stop();
Code inside a KeyListener movieclip :
on (keyPress "<Down>") {
call("myMovie_mc:second_lbl");
}
on (keyPress "<Up>") {
call("myMovie_mc:first_lbl");
}
The code inside your first_lbl Label of myMovie_mc movie clip will be execute.
Download the source for this sample : call.fla !
As the Flash Help Documentation Panel said, The call() action operates synchronously; any ActionScript that follows a call() action does not execute until all of the ActionScript at the specified frame has completed.
So my advice is to create different frame with different script to divide and reduce your actions in as many snippets as you can.
The call() method permits you to better organize your code and it's an easy way to make it maintainable.






















Marco,
Macromedia calls these "function clips".
The good thing is they are now documented in the FL 1.1 pdf's that ship with Flash 8 ... (nice job Mike Krisher ... I think I saw your name in there somewhere).
One thing that isn't mentioned, was a "tip" that in one of the MAX XD sessions (John Ulm I believe?) ... was to separate all the function calls on different layers in an mc and then also make frame labels that correspond to your function calls.
Makes it easier to maintain and pin AS, etc ...
I'll post a sample of this if someone doesn't beat me to it first.
Posted by: Scott Janousek | October 22, 2005 at 03:39 AM
Hi Scott,
the tecnoque you described is something like I did on the Fla you can download from my post ?
Posted by: Marco Casario | October 22, 2005 at 04:09 AM