AS3 - gotoAndStop 立即采取行动 [英] AS3 - gotoAndStop with immediate action
本文介绍了AS3 - gotoAndStop 立即采取行动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在从 AS2 迁移到 AS3,并且在发现这种不兼容之前可能有很多人:
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); //where box is a movie on 5th frame
在 AS3 中最简单的方法是什么.
What is the easiest way how to do it in AS3.
推荐答案
有一个简单的方法可以解决这个问题,但没有记录:
There is an easy way to solve this, but it is undocumented:
addFrameScript(1, update);
gotoAndStop(2);
function update() {
trace(box); // outputs [object MovieClip]
}
请注意,addFrameScript 的第一个参数是帧号,但它是基于 0 的,即 0 是第 1 帧,1 是第 2 帧,等等……第二个参数是您要调用的函数.
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.
这篇关于AS3 - gotoAndStop 立即采取行动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文