# Trying to add listeners within a class

**URL:** https://forum.kirupa.com/t/trying-to-add-listeners-within-a-class/290958
**Category:** Uncategorized
**Created:** [June 22, 2009, 7:16pm UTC](https://forum.kirupa.com/t/trying-to-add-listeners-within-a-class/290958 "2009-06-22T19:16:08Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![hailmatt69](https://avatars.discourse-cdn.com/v4/letter/h/858c86/32.png) [@hailmatt69](https://forum.kirupa.com/u/hailmatt69)
#### Post date: [June 22, 2009, 7:16pm UTC](https://forum.kirupa.com/t/trying-to-add-listeners-within-a-class/290958/1 "2009-06-22T19:16:08Z")

</div>

I am trying to add mouselisteners to a movieclip on my stage, by utilizing basically an activate class.

I want to do this to save alot of code clutter on my main stage.  
Here is what I did:

drew a simple movieclip, and linked it to action script with:  
Class: project.buttons.gridButton  
Baseclass: flash.display.MovieClip

actions on my main stage:

```auto
 
import gridButton.*
var a:gridButton = new gridButton();
a = activateGrid (myMc);

```

buttonGrid.as:

```auto
 
package project.buttons {
 public class gridButton extends MovieClip{
  import flash.display.MovieClip;
  import flash.events.MouseEvent;
  
  public function activateGrid(myMc:MovieClip) {
   myMc.addEventListener(MouseEvent.ROLL_OVER, onRollOverHandler);
   myMc.addEventListener(MouseEvent.ROLL_OUT, onRollOutHandler);
   myMc.addEventListener(MouseEvent.CLICK, onClickHandler);
   myMc.addEventListener(MouseEvent.MOUSE_DOWN, onPressHandler);
   myMc.addEventListener(MouseEvent.MOUSE_UP, onReleaseHandler);
   // if you want a hand cursor
   myMc.buttonMode = true;
   myMc.useHandCursor = true;
   function onRollOverHandler(myEvent:MouseEvent) {
    trace("Over");
   }
   function onRollOutHandler(myEvent:MouseEvent) {
    trace("Out");
   }
   function onClickHandler(myEvent:MouseEvent) {
    trace("I waited for Press AND Release!!!");
   }
   function onPressHandler(myEvent:MouseEvent) {
    trace("Press");
   }
   function onReleaseHandler(myEvent:MouseEvent) {
    trace("Release");
   }
  }
 }
}

```

when I try to compile i get:  
1017: The definition of base class MovieClip was not found.

I don’t understand what I’m doing wrong, can somebody give me some guidance?

Thanks.
