Is there any way to dispatch event (Action Script 3.0) on some class that every object witch is in that class and have specified listener function could catch that event? . For example I have structure like this:
edit (update class):
class example extends EventDispatcher {
object1 = {subObject1 = {anotherObject1, anotherObbject2}, subObject2}
object2 = {subObject3}
object3
...
}
and I want to some of them have event listeners:
anotherObject1.addEventListener(MyEvent.PART3D_CHANGED, function (e: MyEvent){/*do something*/);
anotherObbject2.addEventListener(MyEvent.PART3D_CHANGED, function (e: MyEvent){/*do something*/);
object3.addEventListener(MyEvent.PART3D_CHANGED, function (e: MyEvent){/*do something*/);
edit: Then I want dispatch event within this class and that every object witch have listeners handle the Event, like this:
this.dispatchEvent(new MyEvent(MyEvent.PART3D_CHANGED))
Like You see I need to dispatch one type Event and I don't need to do it on every object.
From my studies I figured it out that I need to dispatch Event on every single object but having many sub objects the code will be untidy if I had to dispatch for every single one with need listener and another option for looping the children of every objects and adding listeners without care if is there need for listener will be no cost efficiency. p.s. Sorry for my English:-)