# How do I use mouse detection inside a class?

**URL:** <https://forum.kirupa.com/t/how-do-i-use-mouse-detection-inside-a-class/188625>\
**Category:** Uncategorized\
**Created:** [May 9, 2006, 2:53pm UTC](https://forum.kirupa.com/t/how-do-i-use-mouse-detection-inside-a-class/188625 "2006-05-09T14:53:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![BlueD](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/blued/32/2074_2.png) [@BlueD](https://forum.kirupa.com/u/BlueD)\
**Post date:** [May 9, 2006, 2:53pm UTC](https://forum.kirupa.com/t/how-do-i-use-mouse-detection-inside-a-class/188625/1 "2006-05-09T14:53:46Z")

</div>

I’m writing a class to create a menu for my new website and I have a question:

If I create the object with AS, how can I attach the classic on(over) etc… to the object I’m creating?

Do I have to extend MovieClip or something like that?

my class is

```auto
class menuBar{
    public function class(mc:MovieClip) {

        draw(mc, Math.round(Stage.height*15/100), Stage.width, 0, Stage.height-Math.round(Stage.height*15/100));
    }
    private function draw(root:MovieClip, h:Number, w:Number, myX:Number, myY:Number) {
        root.beginFill(0x000000);
        root.moveTo(myX,myY);
        root.lineTo(w,myY);
        root.lineTo(w,myY+h);
        root.lineTo(myX,myY+h);
        root.lineTo(myX,myY);
        root.endFill(); 
    }

}

```

and in the main there is only

```auto
var newMenu:menuBar = new menuBar(mcMenu);

```

where mcMenu is a MovieClip that contains the menu. How can I make the menu reacting to the mouse?
