Archive

Archive for April, 2010

AS3 Signals – Threat to Event Dispatcher

April 17, 2010 5 comments

Hi all! Most of you would have predicted now what i gonna discuss here by reading title of this post. Yup I gonna speak about the AS3 signals developed by flex geek Rob Penner which is doing rounds in flash community quite some time.  Though this post meant for As3 signals, i gonna discuss about the pitfalls of Event Dispatching system. (Forgive people i could not explain the pitfalls as Rob penner mentioned but I try to list out some which i felt bad in my development experience).

Pitfalls of flash Event Dispatching system

  • We had situation to create custom event for just sending a values along with the event we dispatch. It might not sound really bad but to make it happen we should extend any subclass of IEventDispatcher class, override clone method, need to receive additional properties via constructor and   assign to public variable so that listener functions could access it. It has not ended here. Eg. If you would like to pass additional properties along with mouse event, you have to create one and create another custom event for  another event type atlast we will end up with lot of boiler plate code.
  • Event could be listened only by the ancestors of the component which is dispatching event. But most of the cases we need to listen an event in many components  which are not ancestors of dispatching component and obviously we would listen an event in system manager or stage as we could listen any event triggered in the app from anywhere. But the real gotcha is when we remove an event listener in one place and all other listener will be removed.
  • We dont have utility function which would listen an event only at once instead of that we should manually remove an event listener once it has been fired as well as we dont have event methods which would remove all the listeners for a  particular event type.
Categories: FLEX