Solvednon blocking while loops in action script?

Posts 1–3 of 3 · Page 1 of 1
non blocking while loops in action script?
Trying to make something that periodically updates on a given interval that doesn't block the rest of the program. Is this possible in action script? In python we can use multiprocessing/threading or asyncio.
Don't think actionscript has this. Your best bet is putting what you're doing into the update loop.
You can use Timer class:
Code:
private const timer:Timer = new Timer(1000); //set interval

public function MyClass() { //constructor
    timer.addEventListener(TimerEvent.TIMER, onTimer); //remember to remove this listener when stopping the timer
    timer.start();
}

private function onTimer(e:TimerEvent):void {
    //do stuff
}
For simple stuff, however, you should just stick your code in the update loop.
Posts 1–3 of 3 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Talk with us