2 Replies Latest reply on Jun 9, 2008 6:40 PM by Gregory Lafrance

    dispatchEvent() and isDefaultPrevented() - not asynchronous ???

    Gregory Lafrance Level 6
      In one class I use dispatchEvent(new ToggleEvent(ToggleEvent.TOGGLE_ATTEMPT).

      Just below that I execute code only if isDefaultPrevented() is false:

      In the event handler for the ToggleEvent I set e.preventDefault() based on a condition.

      My tests indicate that the if(!toggleEvent.isDefaultPrevented()) code will not be reached till after the event handler for the ToggleEvent has returned, which is good, but I did not think I could depend on this, as I thought Flex was asynchronous in this regard.

      I would have thought that code following dispatchEvent() would execute immediately after the call to dispatchEvent(), and not wait till the event handler is done. In this case isDefaultPrevented() is false, as it has not been set yet in the event handler.

      Can I rely on the fact that code after dispatchEvent() (checking isDefaultPrevented()) will not execute until after all event handlers for the dispatched event have returned?

      Thanks very much in advance!!!