# Using mc class in hit test

**URL:** <https://forum.kirupa.com/t/using-mc-class-in-hit-test/276261>\
**Category:** Uncategorized\
**Created:** [November 25, 2008, 3:46am UTC](https://forum.kirupa.com/t/using-mc-class-in-hit-test/276261 "2008-11-25T03:46:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryrocks](https://avatars.discourse-cdn.com/v4/letter/r/ba9def/32.png) [@ryrocks](https://forum.kirupa.com/u/ryrocks)\
**Post date:** [November 25, 2008, 3:46am UTC](https://forum.kirupa.com/t/using-mc-class-in-hit-test/276261/1 "2008-11-25T03:46:57Z")

</div>

Hey everyone,  
In my platform game my character shoots bullets from a gun, these bullets are loaded from a ‘bullet’ class. A new instance of this class has the variable name ‘bulletVar’. I can adjust the bullets x and y position like so:

```
 bulletVar.x = 253;

```

But I also want to use it in a hitTestObject, I thought that the following code would work, but it does not!

stage.addEventListener(Event.ENTER\_FRAME, hitEnemy);  
function hitEnemy(event:Event):void  
{  
if (bulletVar.hitTestObject(enemy\_mc))  
{  
enemy\_mc.gotoAndStop(“dead”);  
stage.removeEventListener(Event.ENTER\_FRAME, hitEnemy);  
}  
}  
Also - how would I then remove that hitting bullet from the movie?

Here’s my code to call a bullet:

var bulletVar:bullet = new bullet();  
this.addChild(bulletVar);

Thanks a lot,

Ryan
