Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Actionscript 3: get display object at pixel

How can I enumerate display objects under a pixel relative to the stage?

Clarification: I want to write a function which get (x,y) as input and returns an array of objects as output.

update: I want to avoid looping over all the display objects, to tell which one is under the specified pixel.

like image 612
George Avatar asked Apr 14 '09 14:04

George


1 Answers

Any DisplayObjectContainer (such as a MovieClip or the stage) has a method called getObjectsUnderPoint that returns an array of display objects under that point. It takes a Point object as an argument.

var myObjects: Array = stage.getObjectsUnderPoint(new Point(5, 5));

If you are using it in a class don't forget to import flash.geom.Point;

like image 91
Bryan Grezeszak Avatar answered Nov 14 '22 04:11

Bryan Grezeszak