Search code examples
flashactionscript-3swc

Actions on timeline frames using baseclass in actionscript


I have fla file with a movieclip. The movieclip has a baseclass where some actions are performed. This fla is exported as an swc. What I want is to be able to add actions to the movieclip from it's base class, without having to do it like onEnterFrame.

Ideas?


Solution

  • There's an undocumented method within MovieClip called addFrameScript which will do exactly that:

    myMc.addFrameScript(2, myFunction);
    
    function myFunction() {
       trace("this is the 3rd frame");
    }
    

    (the frame number is zero based instead of one based like gotoAndPlay's)