# Detecting clicked overlapping movie clips

**URL:** <https://forum.kirupa.com/t/detecting-clicked-overlapping-movie-clips/28360>\
**Category:** Uncategorized\
**Created:** [August 12, 2003, 11:47pm UTC](https://forum.kirupa.com/t/detecting-clicked-overlapping-movie-clips/28360 "2003-08-12T23:47:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmg](https://avatars.discourse-cdn.com/v4/letter/j/e68b1a/32.png) [@jmg](https://forum.kirupa.com/u/jmg)\
**Post date:** [August 12, 2003, 11:47pm UTC](https://forum.kirupa.com/t/detecting-clicked-overlapping-movie-clips/28360/1 "2003-08-12T23:47:14Z")

</div>

Hi, i have a flash 5 app where i can drag movie clips around the stage. They can overlap, and when i click on one i move it, but when they overlap, how can I select only one movie clip, and the one that is on top. I have a button that lets me swap depths for each movie clip so I want to select only the one movie clip.

Thanks for your help, this is urgent.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 14, 2003, 10:39am UTC](https://forum.kirupa.com/t/detecting-clicked-overlapping-movie-clips/28360/2 "2003-08-14T10:39:46Z")

</div>

place your button inside that movie clip. and instead of directly placing a number on the swapDepths, use a variable on the movie clip’s previous timeline. for example you have a movie clip with a button on it use this script:

```auto

on(release){
this.swapDepth(_parent.top);
}

```

and on the timeline where your movie clip is placed place this script:

```auto

top = 9999;

```

so when, for example you have 5 movie clips on the same timeline, when you select anyone of them they go to the depth specified by the variable top which in this case 9999.

Hope this helps! 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 14, 2003, 3:52pm UTC](https://forum.kirupa.com/t/detecting-clicked-overlapping-movie-clips/28360/3 "2003-08-14T15:52:48Z")

</div>

But when they overlap, all the objects that are overlapping will come back true with a hit test… so how do i determine which one of the overlapping ones is on the highest level?
