Hi everyone, I don’t know if i’ve been in front of my computer for too long, but I can’t for the life of me understand why this doesn’t work:
All i’m trying to do is dispatch an event from one class to the other, when I trace it out, it says the event is getting added, but the event listener isn’t picking anything up.
Main.as
package {
import Test;
import flash.display.Sprite;
import flash.events.Event;
public class Main extends Sprite {
public function Main() {
var newTest:Test = new Test();
addChild(newTest);
newTest.addEventListener("test", tester, false, 0, true);
}
private function tester(e:Event):void {
trace("why didn't this work?");
}
}
}
Test.as
package {
import flash.display.Sprite;
import flash.events.Event;
import flash.events.EventDispatcher;
public class Test extends Sprite {
public function Test() {
dispatchEvent(new Event("test", true, false));
}
}
}
Thanks!