Does dispatching an event interrupt a function?

actionscript, apache-flex, flash, flex3

Solution

No, `foo()` will not be interrupted.

Flex is single-threaded, so `foo()` will continue running. Once foo() finishes and control is returned to the event loop, then the first event in the event queue will be processed.

Problem

Let's say function foo() is executing. Suppose that an external event occurs, for which you have a handler. Will function foo() be interrupted so that the event handler can be executed? What is the order of execution in this situation?

Original source