我正在使用 flash pfofessional CC for iOS 和 android 使用 air sdk 15 开发应用程序。他们是否有任何停止代码执行的方法,他们的任何函数都可以执行此操作,喜欢
pause(for_seconds);
没有 sleep 函数,但您可以延迟函数的调用:
function delayedFunctionCall(delay:int) {
trace('going to execute the function you passed me in', delay, 'milliseconds');
var timer:Timer = new Timer(delay, 1);
timer.addEventListener(TimerEvent.TIMER, launch);
timer.start();
}
function launch(e:TimerEvent):void{
timer.removeEventListener(TimerEvent.TIMER, launch);
yourFunction(); // <----
}
您也可以尝试这样做:
var timeToWait:int=100;
startTime = getTimer();
while(getTimer() - startTime < timeToWait){}