AS3 - gotoAndStop with immediate action

后端 未结 2 525
青春惊慌失措
青春惊慌失措 2021-01-19 01:55

I\'m moving from AS2 to AS3 and probably as many ppl before found this incompatibility:

I used quite often code like:

gotoAndStop(5);
trace(box); //w         


        
2条回答
  •  鱼传尺愫
    2021-01-19 02:49

    There is an easy way to solve this, but it is undocumented:

    addFrameScript(1, update);
    gotoAndStop(2);
    
    function update() {
        trace(box); // outputs [object MovieClip]
    }
    

    Please note that the first argument for addFrameScript is the frame number but it's 0-based, i.e. 0 is frame 1, 1 is frame 2, etc... The second argument is the function you would like to call.

提交回复
热议问题