Just a quick function that you can use in your library of tricks to simulate pausing in Actionscript 3.
1 2 3 4 5 6 7 8 9 10 11 | public static function pause(timeInSeconds:int, functionToCall:Function):void { var timer:Timer = new Timer(timeInSeconds * 1000); timer.addEventListener(TimerEvent.TIMER, callFunction, false, 0, true); timer.start(); function callFunction(event:TimerEvent):void { timer.stop(); timer.removeEventListener(TimerEvent.TIMER, callFunction); timer = null; functionToCall(); } } |
The function takes 2 arguments:
timeInSeconds – how many seconds to wait before calling the function
functionToCall – the function to call after the given time has passed


