AS3: addFrameScript and BigMovieClip
Coming off the heels of this blog post about dynamically attaching code to frames in AS3, I decided to foray into ending the use of timeline code altogether.
I failed.
But I did come up with a handy dandy script that will certainly come closer.
Click on for the script and documentation.
AS3 BigMovieClip
AS3 FrameEvent
What It Does
On construction, it combs through the list of all frame labels on the timeline and indexes them in an object. From there, you can assign methods to specific frame labels by virtue of:
addMethodToLabel($label:String,$evt:Function):void
Example: myClip.addMethodToLabel("MY_LABEL",_onMyLabelIn); // function _onMyLabelIn fired when we hit frame label "MY_LABEL"
To remove?
removeMethodFromLabel($label:String):void
In addition, EVERY frame label dispatches a FrameEvent, allowing you the option to listen and act on frame labels from wherever you want. Each FrameEvent object contains a FrameLabel (flash.display.FrameLabel), so you know which clip, frame and label has been reached.
May 16th, 2007 by Stephen / 8 Comments

