Detecting clicked overlapping movie clips

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.

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:


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

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


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! :slight_smile:

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?