Yeah, I have read the documentation for the new event model but I am
having a few issues. Here is a simple example of what I am trying.
Maybe you could give me some insight as to what I am doing wrong:

package com.test {
        
    import flash.display.Sprite;
    import flash.events.Event;
    import com.test.EventManager;
    import mx.controls.Alert;
    
    public class TestDispatcherClass extends Sprite {

        public function TestDispatcherClass() 
        {
            this.dispatchEvent(new Event("action"));
        }
    }
}


the class that will handle the event and get data from the dispatcher:

package com.test {
        
        import com.test.EventManager;
        import flash.events.EventDispatcher;
        import flash.events.Event;
        import mx.controls.Alert;
        import flash.display.Sprite;
        
        public class TestHandler extends Sprite  {
                
        public function TestHandler()
        {
            this.addEventListener("action", actionHandler);
        }
                
        public function actionHandler(event:Event):void 
        {
            Alert.show("hanlded event:" + event.toString());
        }
    }
}

.mxml:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute" xmlns="*" creationComplete="this.initApp();">

     <mx:Script>
        <![CDATA[
                     
        import com.test.TestHandler;
        import com.test.TestDispatcherClass;

        private var test:TestHandler;
        private var dispatcher:TestDispatcherClass;
                    
        private function initApp():void {
                this.test = new TestHandler();
                this.dispatcher = new TestDispatcherClass();
        }
        ]]>
    </mx:Script>
</mx:Application>

Any Ideas???




--- In [email protected], "Jeremy Lu" <[EMAIL PROTECTED]> wrote:
>
> All your classes can extends flash.events.EventDispatcher then they
can just
> fire a
> 
> this.dispatchEvent(new MyEvent(aaa, bbb, ccc));
> 
> other classes can use addEventListener("XMLParsed", someHandler) to
handle
> the event.
> 
> or you can take a look at how Cairngorm use Cairngorm Event
dispatcher as a
> cetralized event center to dispatch event for every class.
> 
> 
> Jeremy.
> 
> On 7/11/06, efeminella <[EMAIL PROTECTED]> wrote:
> >
> >   Does anyone have any simple examples of how to dispatch and handle
> > events between 2 classes. For example how can I have a class that
> > loads and parses xml and then dispatch an event which another class
> > handles and the event and displays the data. Sort of like we did in AS
> > 2 with event.target...
> >
> > Thanks in advance,
> > Eric Feminella
> >
> >  
> >
>







------------------------ Yahoo! Groups Sponsor --------------------~--> 
Great things are happening at Yahoo! Groups.  See the new email design.
http://us.click.yahoo.com/TISQkA/hOaOAA/yQLSAA/nhFolB/TM
--------------------------------------------------------------------~-> 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to