# EventListener listen for Object in Different Class

**URL:** <https://forum.kirupa.com/t/eventlistener-listen-for-object-in-different-class/282584>\
**Category:** flash\
**Created:** [February 23, 2009, 11:13pm UTC](https://forum.kirupa.com/t/eventlistener-listen-for-object-in-different-class/282584 "2009-02-23T23:13:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ThaJock](https://avatars.discourse-cdn.com/v4/letter/t/9de0a6/32.png) [@ThaJock](https://forum.kirupa.com/u/ThaJock)\
**Post date:** [February 23, 2009, 11:13pm UTC](https://forum.kirupa.com/t/eventlistener-listen-for-object-in-different-class/282584/1 "2009-02-23T23:13:28Z")

</div>

I’m having problems with creating a class that holds all the code for my event & listeners that listens for objects that are in a different class.  
package {  
import flash.display._;  
import flash.events._;

```
 public class Prospect extends MovieClip {
      var theLogin:MovieClip = new login();

      public function Prospect () {

      }
 }

```

]

//////////////////////////////////////////////////////////////////////////////////////////////

package {  
import flash.events.\*  
import flash.display.\*;

```
 public class TheEvents extends Prospect implements IEvents {

      public function TheEvents () {

      }
      public function LoginEvents():void {
           theLogin.loginBtn.addEventListener(MouseEvent.CLICK, loginClick);
           function loginClick(event:MouseEvent):void {
                trace('login button clicked');
           }
      }
 }

```

}

//////////////////////////////////////////////////////////////////////////////////////////////

package {  
import flash.display._;  
import flash.events._;

```
 public class Main extends MovieClip {
 var theProspect:Prospect = new Prospect();
 var events:TheEvents = new TheEvents();

      public function Main () {
           addChild(theProspects.theLogin);
           events.LoginEvents();
      }
 }

```

}

Basically I am trying to set the listener to listen for an object that is in a different class.  
When I test my project with this concept I don’t get any errors but I don’t see the trace statement from TheEvents class after I click the loginBtn.

Any help or better way of accomplishing this would be greatly appreciated.
