# How to call a Listener in the Timeline from a class?

**URL:** <https://forum.kirupa.com/t/how-to-call-a-listener-in-the-timeline-from-a-class/258866>\
**Category:** flash\
**Created:** [April 29, 2008, 2:54am UTC](https://forum.kirupa.com/t/how-to-call-a-listener-in-the-timeline-from-a-class/258866 "2008-04-29T02:54:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![leandroeduardo](https://avatars.discourse-cdn.com/v4/letter/l/13edae/32.png) [@leandroeduardo](https://forum.kirupa.com/u/leandroeduardo)\
**Post date:** [April 29, 2008, 2:54am UTC](https://forum.kirupa.com/t/how-to-call-a-listener-in-the-timeline-from-a-class/258866/1 "2008-04-29T02:54:30Z")

</div>

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:

```php

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

```php

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!
