Actionscript设置超时不工作

Actionscript设置超时不工作,actionscript,Actionscript,计时器总是直接跳入函数,而不是等待2000毫秒 stop(); var hey:Number= 2000; function exercise(frame) { trace("sup"); this.gotoAndStop(frame); } setTimeout(exercise(2),hey); trace(hey); setTimeout函数(即非计时器)采用以下参数: public function setTimeout(closure:Function, delay

计时器总是直接跳入函数,而不是等待2000毫秒

stop();

var hey:Number= 2000;

function exercise(frame) {
  trace("sup");

  this.gotoAndStop(frame);
}

setTimeout(exercise(2),hey);

trace(hey);

setTimeout函数(即非计时器)采用以下参数:

public function setTimeout(closure:Function, delay:Number, ... arguments):uint
尝试:


如果你反复这样做,考虑创建一个定时器,并将重置计数设置/重置为1,然后可以在需要时重新启动定时器。

是2微秒吗?检查文档,我不熟悉actionscript。它说场景1,层“层1”,第1帧,第15行1180:调用可能未定义的方法clearTimeOut
// Save the return value so you can clear it later, otherwise your app for leak memory
var myTimeOut:uint = setTimeout(exercise, hey, 2);
trace(hey);
// the timeout closure object will not be garage collected if you do not clear it
clearTimeout(myTimeOut);