Hi all,
I am developing a class in AS3, and I want to use an object (in the .FLA Timeline) as a listener (like in the AS2 MovieClipLoader class).
I have a public method that receives the object (addListener), and I can call the functions normally by pressing a button (_prev, _next).
Class:
private function defineActions() (
this._prev.buttonMode = true;
this._prev.addEventListener (MouseEvent.CLICK, forward)
this._next.buttonMode = true;
this._next.addEventListener (MouseEvent.CLICK, back)
)
public function addListener(listener:Object) {
this._listener = listener;
}
private function forward(evento:MouseEvent) {
this._listener.fnFoward(); // Ok, the function will be called in the .FLA and traces "ok"
}
private function back(evento:MouseEvent) {
this._listener.fnBack(); // Ok, the function will be called in the .FLA and traces "ok"
}
private function enable(mc: MovieClip, var1: Boolean) {
var1? this._listener.fnEnabled(mc): this._listener.fnDisabled(mc); // Returns TypeError: Error # 1006: desabilitar is not a function.
}
.FLA
var ouvinte:Object = new Object();
var ts:CheckSetas = new CheckSetas();
ts.addListener(ouvinte);
ouvinte.fnFoward = function() { trace("ok") }
ouvinte.fnBack = function() { trace("ok") }
ouvinte.fnEnabled= function(target:MovieClip) { trace("enabled"); }
ouvinte.fnDisabled= function(target:MovieClip) { trace("disabled");}
The problem is when I am trying to call the listener from a function and not through an event. I have traced the object inside the “enable” function and it’s ok.
Does anyone know why this happens?
Thanks,
Leandro
Ps.: Sorry for my poor english!