views:

409

answers:

1

I have a flex app that has several timers running for various amounts of time and for various reasons. I'd like to be able to stop all timers running if the user goes over a specified amount of time, but don't want to individually stop the timers using timer.stop();

Is there a way to stop all timers globally or find and iterate over all timers running and stop them?

+5  A: 

You could register all your timers onto a TimersManager class, something like:

var t:Timer = new Timer()
TimersManager.getInstance().register(t);
...
TimersManager.getInstance().stopAll();

the implementation of that class should be pretty trivial. Just make sure you keep weak references to those timers.

sharvey