Thanks that makes sense On 4 Mar 2015 21:43, "Ronny Shibley" <[email protected]> wrote:
> Think of it like calling a method. There are no timers and no multiple > threads. If an event is dispatched in the middle it bubbles up and then > original event continues bubbling up. > > Ronny Shibley > > > On Mar 4, 2015, at 11:30 PM, Mark Line <[email protected]> wrote: > > > > Hi, > > > > I was wondering if someone could confirm something for me about event > > processing. I know if you two events are dispatched one after another, > the > > second event will be dispatched only after all handlers of the first > event > > are executed and the dispatchEvent method is returned. > > > > However does anyone know what would happen if during the event processing > > of the first event it dispatched another event. Would the new event be > > processed before any of the other event listeners (think event life cycle > > if it was bubbling). > > > > A very basic example: > > > > <?xml version="1.0" encoding="utf-8"?> > > <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" > > xmlns:s="library://ns.adobe.com/flex/spark" > > xmlns:mx="library://ns.adobe.com/flex/mx" > > creationComplete="init(event)"> > > > > <fx:Script> > > <![CDATA[ > > import mx.events.FlexEvent; > > protected function button1_clickHandler(event:MouseEvent):void > > { > > trace("button1_clickHandler"); > > this.dispatchEvent(new FlexEvent(FlexEvent.CHANGE_END)); > > } > > protected function eventOneHandler(event:Event):void > > { > > trace("eventOneHandler"); > > this.dispatchEvent(new FlexEvent(FlexEvent.CHANGE_START)); > > eventThreeHandler(new Event("blah")); > > } > > protected function eventTwoHandler(event:Event):void > > { > > trace("eventTwoHandler"); > > } > > protected function eventThreeHandler(event:Event):void > > { > > trace("eventThreeHandler"); > > } > > protected function init(event:FlexEvent):void > > { > > this.addEventListener(FlexEvent.CHANGE_END, eventOneHandler); > > this.addEventListener(FlexEvent.CHANGE_START, eventTwoHandler); > > } > > ]]> > > </fx:Script> > > > > <fx:Declarations> > > <!-- Place non-visual elements (e.g., services, value objects) here --> > > </fx:Declarations> > > > > <s:Button label="Click me" > > click="button1_clickHandler(event)"/> > > </s:Application> > > > > > > Eg would Flex make sure the event handlers registered for my > > this.addEventListener(FlexEvent.CHANGE_START, > > eventTwoHandler) before return flow to the button1_clickHandler. >
