# Duplicating Movie Clips With hitTest

**URL:** <https://forum.kirupa.com/t/duplicating-movie-clips-with-hittest/150755>\
**Category:** programming\
**Created:** [June 10, 2005, 3:03am UTC](https://forum.kirupa.com/t/duplicating-movie-clips-with-hittest/150755 "2005-06-10T03:03:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheCanadian](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@TheCanadian](https://forum.kirupa.com/u/TheCanadian)\
**Post date:** [June 10, 2005, 3:03am UTC](https://forum.kirupa.com/t/duplicating-movie-clips-with-hittest/150755/1 "2005-06-10T03:03:01Z")

</div>

I’m using Flash MX 2004 Pro and AS2.

I have 2 moviclips - one player controlled (named “circle”) and one set in random motion (named “triangle”). When the two collide I want the triangle mc to be removed and a new to be created in a random spot.  
I have the code to make this happen with a button press:

```auto

on (press) {
triangle.duplicateMovieClip("triangle", this.getNextHighestDepth(), {_x:20, _y:20});
}

```

This code made it so when I pressed the button, a new mc was created at the coordinates 20,20. But when I try to put it into an onClipEvent handler on the triangle mc it doesn’t do anything:

```auto
 
onClipEvent (enterFrame) {
if (this.hitTest(_root.circle)) {
triangle.duplicateMovieClip("triangle1", this.getNextHighestDepth(), {_x:20, _y:20});
}
}

```

Could someone please explain how to remove the triangle mc and place a new one on the stage at a random spot when it collides with the circle mc.

Any help would be appreciated. Thanks.
