Yes, that would be correct. I initially named them MyEvent/ListenerClass but changed it halfway through writing the email.
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Helmut Granda Sent: Tuesday, April 03, 2007 11:54 AM To: flashcoders@chattyfig.figleaf.com Subject: Re: [Flashcoders] Events for custom classes? Thanks for this sample David, Just a small correction: public function ListenerClass(eventClass:MyEventClass) should be public function ListenerClass(eventClass:EventClass); Correct? -h On 4/3/07, David Ngo <[EMAIL PROTECTED]> wrote: > > You'll need a reference of the dispatching class in your listener class to > receive events: > > // broadcasting class > import mx.events.EventDispatcher; > > class EventClass > { > // EventDispatcher methods > public var addEventListener:Function; > public var removeEventListener:Function; > private var dispatchEvent:Function; > > public function EventClass() > { > > } > > public function onInit():Void > { > trace('onInit fired!'); > dispatchEvent({type: "onInit", target: this}); > } > } > > > // listener class > import mx.utils.Delegate; > > class ListenerClass > { > public function ListenerClass(eventClass:MyEventClass) > { > eventClass.addEventListener("onInit", Delegate.create > (this, > onInitHandler)); > } > > private function onInitHandler(event:Object):Void > { > trace('onInitHandler invoked'); > } > } > > > // implementation > var eventClass:EventClass = new EventClass(); > var listenerClass:ListenerClass = new ListenerClass(eventClass); > eventClass.onInit(); > > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Merrill, > Jason > Sent: Tuesday, April 03, 2007 9:47 AM > To: flashcoders@chattyfig.figleaf.com > Subject: RE: [Flashcoders] Events for custom classes? > > Actually, I had been meaning to post again because I had lost my code > for getting EventDispatcher working between two classes. Someone posted > a response here and I lost it, as well as my code that was working. if > anyone can post again on how to get one class to dispatch a CUSTOM event > and get another CUSTOM class to listen to that event, please post! > Helmut and I would like to see an example. The help docs on > EventDispatcher are really awful, and I haven't seen a lot of stuff > online. > > Jason Merrill > Bank of America > GT&O Learning & Leadership Development > eTools & Multimedia Team > > > > > >>-----Original Message----- > >>From: [EMAIL PROTECTED] > >>[mailto:[EMAIL PROTECTED] On Behalf > >>Of Helmut Granda > >>Sent: Tuesday, April 03, 2007 12:35 PM > >>To: Flashcoders mailing list > >>Subject: Re: [Flashcoders] Events for custom classes? > >> > >>On 4/3/07, Helmut Granda <[EMAIL PROTECTED]> wrote: > >>> > >>> Jason, > >>> > >>> Were you able to figure this out exactly the way you wanted it? > >>> > >>> -h > >>> > >>> On 2/16/07, Merrill, Jason < [EMAIL PROTECTED]> wrote: > >>> > > >>> > Ah - nevermind - figured out I had removed the scope to my > >>> > webservice and forgot to put it back in. Delegate works > >>fine for me > >>> > now, sorry about the noise, and thanks so much everyone > >>for the help!! > >>> > > >>> > Jason Merrill > >>> > Bank of America > >>> > Learning & Organizational Effectiveness > >>> > > >>> > > >>> > > >>> > > >>> > > >>> > > >>> > > >>_______________________________________________ > >>Flashcoders@chattyfig.figleaf.com > >>To change your subscription options or search the archive: > >>http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > >> > >>Brought to you by Fig Leaf Software > >>Premier Authorized Adobe Consulting and Training > >>http://www.figleaf.com http://training.figleaf.com > >> > _______________________________________________ > Flashcoders@chattyfig.figleaf.com > To change your subscription options or search the archive: > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > Brought to you by Fig Leaf Software > Premier Authorized Adobe Consulting and Training > http://www.figleaf.com > http://training.figleaf.com > > _______________________________________________ > Flashcoders@chattyfig.figleaf.com > To change your subscription options or search the archive: > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > Brought to you by Fig Leaf Software > Premier Authorized Adobe Consulting and Training > http://www.figleaf.com > http://training.figleaf.com > _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com