Thank you problem solved!

--- In [email protected], "ben.clinkinbeard"
<[EMAIL PROTECTED]> wrote:
>
> this.addEventListener means you're listening on the application, not
> on modelLocator. Unless the event bubbles, this will not work. Either
> make the event bubble or listen on modelLocator.
> 
> HTH,
> Ben
> 
> 
> --- In [email protected], "guillaumeracine"
> <guillaume.racine@> wrote:
> >
> > I did a sample app to test a custom event.
> > I have a class named ModelLocator that extends EventDispatcher.
> > This class dispatch an event of type TreeDataLoadedEvent.
> > The main application listen to it but it seems that it never catch the
> > TreeDataLoadedEvent object that is dispatched.
> > Is it because the modelLocator object is not a child of the
application?
> > 
> > If so how to get this thing done...
> > 
> > <mx:Application
> >     xmlns:mx="http://www.adobe.com/2006/mxml";
> >     layout="absolute"
> >     creationComplete="creationCompletedHandler(event);">
> >     
> >     <mx:Script>
> >             <![CDATA[
> >                     import events.TreeDataLoadedEvent;
> >                     import model.ModelLocator;
> >                     import mx.controls.Alert;
> >                     
> >                     public var modelLocator:ModelLocator = 
> > ModelLocator.getInstance();
> >                     
> >                     private function btnClicked(evt:Event):void{
> >                             modelLocator.dispatchEvent( new 
> > TreeDataLoadedEvent() );
> >                     }
> >                     
> >                     private function eventReceived(evt:Event):void{
> >                             Alert.show("Event received!"); //This is not 
> > shown
> >                     }
> >                     
> >                     private function 
> > creationCompletedHandler(evt:Event):void{
> >                             this.addEventListener( 
> > TreeDataLoadedEvent.LOAD_COMPLETED_EVENT,
> > eventReceived );
> >                     }
> >             ]]>
> >     </mx:Script>
> >     
> >     <mx:Button id="btn" x="209" y="299" label="Button"
> > click="btnClicked(event);"/>
> >     
> > </mx:Application>
> >
>


Reply via email to