Can anyone please explain me why the dispatched event is not captured in this code?
The idea here was to notify all instances of a class when you click on one of them.
package sample{
import flash.events.EventDispatcher;
import flash.events.MouseEvent;
import flash.display.MovieClip;
import flash.events.Event;
public class labels extends MovieClip {
var dispatcher:EventDispatcher = new EventDispatcher();
public function labels() {
this.buttonMode = true;
this.addEventListener(MouseEvent.CLICK, butClick);
this.addEventListener("bla-bla", capture);
}
public function butClick(e:MouseEvent) {
dispatcher.dispatchEvent(new Event("bla-bla"));
trace("clicked: " + e.currentTarget);
}
function capture(e:Event) {
trace(e.currentTarget + ": one of us have been clicked!");
}
}
}
Thanks!