# Mouse position and hitTest

**URL:** <https://forum.kirupa.com/t/mouse-position-and-hittest/250794>\
**Category:** Uncategorized\
**Created:** [February 1, 2008, 4:40pm UTC](https://forum.kirupa.com/t/mouse-position-and-hittest/250794 "2008-02-01T16:40:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hoolagon](https://avatars.discourse-cdn.com/v4/letter/h/58956e/32.png) [@hoolagon](https://forum.kirupa.com/u/hoolagon)\
**Post date:** [February 1, 2008, 4:40pm UTC](https://forum.kirupa.com/t/mouse-position-and-hittest/250794/1 "2008-02-01T16:40:12Z")

</div>

Hi, Im new to AS3 and am trying really hard to convert my AS2 code to AS3. I keep making break throughs only to get stuck again. The current problem is trying to detect a hitTest with the cursor. I use this code very successfully in AS2, when I cannot use an rollover for whatever reason.

This is my AS2 code:

```php
onEnterFrame = function()
{
   if(my_mc.hitTest(_root._xmouse, _root._ymouse))
   {
      race("the mouse is positioned over my_mc") 
   }
} 

```

This is me trying unsuccessfully to convert it to AS3:

```php
stage.addEventListener(Event.ENTER_FRAME, intro); 
function intro(e:Event):void
{
     my_mc.hitTest(mouseX, mouseY)
     {
        trace("the mouse is positioned over my_mc")
     }
} 

```

Anyone know where Im going wrong?
