addFrameScript with parameters
Posted: September 20th, 2007 | Author: Ivan Valadares | Filed under: Actionscript3, Code | 6 Comments »There is a little __undocumented__ function that can be very useful sometimes called addFrameScript. It allows you to specify a function that is called when the playhead of the Movieclip timeline enters the specified frame number. This can be a great improvement if you don’t want to write code directly on the timeline or if you don’t want to add an EnterFrame listener to the movieClip.
MovieClip.addFrameScript(frame_number:uint,function_to_call:Function)
Example:
Note: The frame number are zero based (0 to totalframes-1)
This function works well, but it’s impossible to pass arguments to the caller function. After a little research we found Ian Thomas delegate class.
Using delegate class is possible to call a function with arguments in situations that normally you couldn’t. So for addFrameScript we did: