3

Is there any way to get the top most UI element in a specific x,y location?

Shahed
  • 898
  • 1
  • 12
  • 25

1 Answers1

6
var objects:Array = stage.getObjectsUnderPoint(new Point(x, y));

Where objects[0] will be the top most object. (I think)

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/DisplayObjectContainer.html#getObjectsUnderPoint()

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
  • 1
    Also 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