While building a basic Event system is not a big problem in AS3, take into accounts all special cases can be very troublesome. Some of the most significant ones are
Priority – how can we handle events more effective ? the numbering sorting priority system seems to be ugly, non dense and can not ensure things to work correctly. What if a component thinks that it should be call first, or call last, then another one thinks that, too ?
Cancelable – it will be based on the priority, how we can ensure that our callbacks would stop the dispatching stream before any other guys get updated. Should we have some kind of internal dispatching / callback to update internal things first ?
Recursive – there are case when we click something, active it, then on the handler, after doing something, we set active back to some other value, the event system may not be working as expected ? May be we should add some variable and check if it’s dispatching, if yes, just defer new dispatchings till next frame
Loop back – while we are trying to use some set of components that are someway bind to another, changing one can dispatch an event to change another, which can be looped back to change the dispatch source, which can cause an unstoppable loop for normal case, and blink loop for defer dispatching case (defer dispatching won’t solve this). We can add some kind of changes detection before dispatching, but it can be not accuracy after some data conversion, particularly for Numbers where we need to take round off errors into account.
Validation – before sending update to all the registered listeners, we may need to validate the value to ensure the changed value is valid. How can we do that? What if there are not only one validators out there, and then will their priority affects ?
Update skipping – While it’s best practice trying to update the View based on Model event, there are some case that updating the view directly boost the performance dramatically. How we handle this case ? can we add some kind of dispatching target (not the Dispatching Object itself) so we can check and skip / only update necessary things while getting the event back from Model ?