getObjectsUnderPoint to basic

since i couldn’t find any answer from googling, i’m pretty sure, this will be the answer to all.

my problem is really simple yet i can’t solve it.

How do you get a name from getObjectsUnderPoint ?

====================

i have 3 movieclips made manually, a, b and c.

a is on stage. b and c are inside a.

the code is this


stage.addEventListener(Event.ENTER_FRAME, loop);

function loop(e:Event)
{
    var obj:Array = stage.getObjectsUnderPoint(new Point(mouseX, mouseY));
    
    if (obj[obj.length-1]) trace(obj[obj.length-1].name);
}

now if i test it, the output will be:

instance1
instance1
instance1
instance2
instance2
instance2
instance3
instance3

and so on…

we expect to see a, b and c in the output panel. How do you do that?

thank you all