Reply to comment

prevent stack overflow

I also found this trying to track down some mystery timer that appears in my runtime with a delay of 1500 that I never created. I have a different theory for what AsyncDispatcher is for.

For various design reasons, my program performs iteration on elements mediated by event dispatches. Every time through the loop, the event and the function calls that it initiates get added to the stack. The stack only unwinds when the iteration is done. This works fine for small numbers of iterations, but with > 500 objects or so I was getting stack overflows. I think this kind of situation is a consequence of Flash being single-threaded.

The solution I found is to break the chain by creating a timer. Every time through the loop the timer gets started, which lets the control flow return and unwind the stack back to the GUI event that triggered it. Then when the timer event gets handled we do one iteration and launch the timer again.

I would guess that AsyncDispatcher serves this function without you having to create your own timer and handler.

-Eric Saund
saund@parc.com

Reply

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options