seems to run perfectly fine for me, as for solving your 2 hits in one problem, it seems to me that you could run a script to check which targets the mouse hits, then compare there layer values, and then figure out using some other coding...err, let's see if i can write it down correctly

Code:
foo = 0;
layervalue = -100000000;
hit = nothing;
while(foo<targetsonscreen)(
if(keyIsDown(1))(
if(Math.sqrt(Math.pow(_xmouse-this["mc"+foo]._x,2)+Marg.pow(_ymouse-this["mc"+foo]._y,2)(
if(this["mc"+foo]._layer>layervalue)(
layervalue = this["mc"+foo]._layer; hit = "this["mc"+foo]"; ); ); ); foo++ ); <do whatever>
that's an example of my idea, and if it's correct, it would have the name of the hit target stored in the variable "hit", so... does it work?