I have two .as classes. FaqList, and FaqRow.
Here’s a piece of FaqRow that’s of the essence:
import mx.events.EventDispatcher;
import mx.utils.Delegate;
class FaqRow extends MovieClip {
//vis components
private var questionMC:MovieClip;
private var answerMC:MovieClip;
private var dispatchEvent:Function;
public var addEventListener:Function;
public var removeEventListener:Function;
public static var QUESTION_RELEASED:String = "QUESTION_RELEASED";
public function FaqRow() {
mx.events.EventDispatcher.initialize(this);
}
public function onLoad(Void):Void {
questionMC.onRelease = Delegate.create(this, rowReleased);
}
private function rowReleased(Void):Void {
dispatchEvent(QUESTION_RELEASED);
}
}
Should be self-explanatory enough… my FaqList adds instances of FaqRow to the stage, then I try
//inside some other method
someRow.addEventListener(FaqRow.QUESTION_RELEASED, Delegate.create(this, rowReleased));
private function rowReleased(obj:Object):Void {
trace(obj.target);
}
And wouldn’t you know - I don’t get the trace from FaqList… no errors or anything like that… just fails in that AS2-signature silent way.
I’m 99% sure it’s some silly error that I’m making, I’ve been trying to find it. Reading about EventListeners… can’t figure it out. Maybe someone here with a fresh look on it?