I love the event model in AS3, however I am having a little trouble figuring out how to utilize it in my current situation:
Say for instance I have a **Sprite ** on my stage stored in the document class’ property, ‘container’. I also have multiple instances of a custom class called ‘Ball’ added as children to ‘container’.
Since ‘ball’ extends ‘Sprite’ it is also a subclass of the ‘EventDispatcher’ Class.
In the constructor of ‘ball’ I added Listeners for ‘MouseEvent.MOUSE_OVER’, ‘MouseEvent.MOUSE_OUT’ and ‘MouseEvent.MOUSE_UP’. I also added listeners for custom events. In the MouseEvent handlers, I want to dispatch custom events. For instance, when you rollover one ball, I want to remove a certain listener for that object, run a function to feature that ball (scale up, and move x,y) and dispatch a custom event that lets the other ball instances know to unFeature themselves (scale down, blur, and move x,y). When the user rolls the mouse off the ball, I would add the listener back to the ball and dispatch another event that would tell all ball instances to reset.
With my current understanding of the AS3 event model, it seems like this is impossible using my current logic since Events cannot be dispatched to a parent’s children without dispatching the event multiple times using some kind of loop. Is this correct?
Thanks in advance.