[Flashcoders] EventDispatcher.removeEventListener
I'm having some issues with EventDispatcher, specifically removeEventListener and delegates. The problem arises when I want to remove an existing event listener but the target function no longer exists, is there any way to remove an event listener without specifying the callback function? On a side note, are there any improved alternatives to EventDispatcher? -- Regards, Simen Brekken ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] EventDispatcher.removeEventListener
yup, check out gDispatcher by Mr. Skinner. You can google it. On 2/6/06, Simen Brekken [EMAIL PROTECTED] wrote: I'm having some issues with EventDispatcher, specifically removeEventListener and delegates. The problem arises when I want to remove an existing event listener but the target function no longer exists, is there any way to remove an event listener without specifying the callback function? On a side note, are there any improved alternatives to EventDispatcher? -- Regards, Simen Brekken ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- Ramon Miguel M. Tayag ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] EventDispatcher.removeEventListener
You can also remove a listener from an object using the __q_click array of the object the listener is on. Add a listener like this: cancel_btn.addEventListener(click, Delegate.create(this, this.somefunction)); And remove that listener like this: cancel_btn.removeEventListener(click, cancel_btn.__q_click[0]); If you had multiple listeners, you might be able to loop over the __q_click array and do a comparison but I'm not sure how. Brookd At 12:43 PM 2/6/2006, you wrote: What I've figured out with removeEventListener and Delegate is you can remove the listener on dispatchEvent like so: private function someEventHandler (e:Object) { var target = e.target; if (removeHandler) target.removeEventListener(event, arguments.caller); } Of course this only works after removeHandler is set to true and the event is dispatched once again. Yet, is some instances its enough. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] EventDispatcher.removeEventListener
Or perhaps a bit simpler and safer: var myFunction:Function=Delegate.create(this,somefunction); cancel_btn.addEventListener(click,myFunction); and later: cancel_btn.removeEventListener(click,myFunction); You could always store myFunction as a property... Ian On 2/6/06, blists [EMAIL PROTECTED] wrote: You can also remove a listener from an object using the __q_click array of the object the listener is on. Add a listener like this: cancel_btn.addEventListener(click, Delegate.create(this, this.somefunction)); And remove that listener like this: cancel_btn.removeEventListener(click, cancel_btn.__q_click[0]); If you had multiple listeners, you might be able to loop over the __q_click array and do a comparison but I'm not sure how. Brookd ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders