Actionscript 3: get display object at pixel

后端 未结 2 775
一整个雨季
一整个雨季 2021-01-12 10:40

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

Clarification: I want to write a function which get (x,y)

2条回答
  •  一向
    一向 (楼主)
    2021-01-12 10:56

    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;

提交回复
热议问题