Hi there, I’m having a strange problem dispatching custom events across different classes. Here’s some basic code…
MyEvent.as (extends Event)
public function MyEvent(message : String) {
this.message = message;
}
ClassA.as (extends Sprite)
public function ClassA() {
addEventListener(MyEvent.ACTION, listenerFunction);
}
public function listenerFunction(e : MyEvent) : void {
trace(“HEARD”);
}
ClassB.as (extends Sprite)
public function ClassB() {
dispatchEvent(new MyEvent(“MY MESSAGE”));
}
Now if the event is dispatched in the same class as the event listener is defined, it hears it ok. But the example above doesn’t work! Any ideas guys?
Thanks a lot,
Dave