This content has been marked as final. Show 7 replies
because your events are dispatched by instances and siblings are not in the instance hierarachy.
if you want all the class members to respond to an instance event, store the class members in an array and cycle through them in an event listener function.
Thanks for the quick reply.
I simply don't get it.
I have a root class which adds two different children of different classes. One child dispatched an event, and the other is supposed to get it. Both of the are now supposed to be in the instance hirrarchy, or am I wrong?
Logically, I'd figure this should work smooth and simple without any need for any looping or such.
Right now, the root class can recieve the event dispatched by child1, but I can't make child2 recieve any event dispatched by either the root or child1.
I'd appreciate if you could show me the way...
by root class do you mean a base class? and by adding children of different classes do you mean you have two subclasses that extend your base class and each of those subclasses have an instance? and these two instances need to dispatch events to the other?
No, I mean that I have 3 different classes, all 3 are subclasses of Sprite and Sprite alone.
the root class is called Try1
then there are two classes calles Aobj and Bobj which are both instanciated to the Try1 child-list.
All I want is for Aobj to dispatch an event and for Bobj to listen to that event.
In the example I also tried to catch the event on the root class and re-dispatch it, but that doesn't work as well.
events are not globally transmitted. they are dispatched by specific instances (or classes) and can be detected only by objects in the event flow.
now it works.
thanks a lot.