Is there any way to get the top most UI element in a specific x,y location?
Asked
Active
Viewed 716 times
1 Answers
6
var objects:Array = stage.getObjectsUnderPoint(new Point(x, y));
Where objects[0]
will be the top most object. (I think)

Matt MacLean
- 19,410
- 7
- 50
- 53
-
Very nice. Also, be wary of this function if you have a lot of objects on the screen & are repeating it like in a mouseMove handler since it's not the fastest function there is. – J_A_X Apr 14 '11 at 20:11
-
1Also note that the x,y values are relative to the stage so you may have to use obj.localToGlobal(point) to translate them. – Matt MacLean Apr 14 '11 at 20:13
-
and it is not objects[0], but objects[objects.length-1] that is the top ui element :) I happen to have needed it aswell a few days ago :p – Michiel Standaert Apr 14 '11 at 22:08