Never thought of that and never had to listen to multiple events with the same name !
Thanks for the heads up Muzak! Alain -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Muzak Sent: 7 juin 2007 12:22 To: flashcoders@chattyfig.figleaf.com Subject: Re: [Flashcoders] EventDispatcher weirdness in AS2 Even though it's possible to use the class instance as the listener (this), you're still better off using Delegate. What if you have 2 instances dispatching the same event that need to be handled completely different? submit_btn.addEventListener("click", this); aTotallyUnrelated_btn.addEventListener("click", this); The above will work, but they'll both trigger the same event handler and you'll have to resort to if()else() stuff. No big deal if you have 2 buttons.. get's hairy with loads of buttons. Or what about different components (DataGrid, ComboBox, List, etc..) who all dispatch a "change" event.. _dg.addEventListener("change", this); _cb.addEventListener("change", this); _list.addEventListener("change", this); versus: _dg.addEventListener("change", Delegate.create(this, datagridChangeHandler)); _cb.addEventListener("change", Delegate.create(this, comboChangeHandler)); _list.addEventListener("change", Delegate.create(this, listChangeHandler)); Get in the habit of using Delegate (in AS2) and *always* use it.. no exceptions ;-) regards, Muzak ----- Original Message ----- From: "Alain Rousseau" <[EMAIL PROTECTED]> To: <flashcoders@chattyfig.figleaf.com> Sent: Thursday, June 07, 2007 4:07 PM Subject: RE: [Flashcoders] EventDispatcher weirdness in AS2 > Hehe no prob. > > For your listener are you doing something like > > _myClass.addEventListener("onTransition", Delegeate.create(this, > onTransitionHandler)); > > private function onTransitionHandler() { > //do stuff > } > > don't you prefer > > _myClass.addEventListener("onTransition", this); > > function onTransition() { > //do stuff > } > > for better clarity and less code writing ? No need of delegate in this case. > > Of course it's a question of choice and habit. Just to let you know of the > alternatives ! > > Alain > _______________________________________________ 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 No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.472 / Virus Database: 269.8.11/837 - Release Date: 2007-06-06 14:03 No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.472 / Virus Database: 269.8.11/837 - Release Date: 2007-06-06 14:03 _______________________________________________ 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