# Flash as2 Help with simple hitTest please

**URL:** https://forum.kirupa.com/t/flash-as2-help-with-simple-hittest-please/331227
**Category:** flash
**Created:** [June 17, 2013, 8:26pm UTC](https://forum.kirupa.com/t/flash-as2-help-with-simple-hittest-please/331227 "2013-06-17T20:26:40Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Jason\_Scholz](https://avatars.discourse-cdn.com/v4/letter/j/53a042/32.png) [@Jason\_Scholz](https://forum.kirupa.com/u/Jason_Scholz)
#### Post date: [June 17, 2013, 8:26pm UTC](https://forum.kirupa.com/t/flash-as2-help-with-simple-hittest-please/331227/1 "2013-06-17T20:26:40Z")

</div>

I am pulling my hair out, I have checked several of my flash books, Google, forums, and I cannot seem to get this hitTest to work. 1st frame on the stage (actionscript layer), is where all my code is at. I first, called a movieClip to the stage:

\_root.attachMovie(“enemy01”, “enemy01”, 0());  
enemy01.\_x = 750;  
enemy01.\_y = 300;

Perfect! I got the movieclip! NOW, i want to hitTest this movieclip against the Hero:

if (\_root.Hero.hitTest(\_root.enemy01.\_x, \_root.enemy01.\_y)) {  
removeMovieClip(\_root.enemy01);  
}

No errors, the enemy is attached to the stage at the desired x/y coordinates, and no hitTest working. HOWEVER, if I use this code:

if (\_root.Hero.hitTest(\_root.enemy01.\_x, \_root.enemy01.\_y)) {  
\_root.enemy01.\_visible = false;  
}

The hitTest works perfectly. As soon as the Hero touches the enemy01 from any direction, the enemy01 disappears because of the hitTest. I don’t want the enemy to be hidden, I want the enemy removed from the stage if the Hero hits it. What am I missing?
