English 中文(简体)
Actionscript 3:显示对象像素
原标题:
  • 时间:2009-04-14 14:04:17
  •  标签:

我怎么能枚举显示对象在一个像素相对于舞台?

<强>澄清:< /强>我想写一个函数,得到<强> (x, y) < /强>作为输入,并返回一个<强> < /强>作为输出的对象数组。

<强> < /强>更新:我想避免循环显示对象,告诉哪一个是在指定的像素。

最佳回答

任何DisplayObjectContainer(如影片剪辑或阶段)有一个方法叫做getObjectsUnderPoint下的显示对象返回一个数组。它需要一个点对象作为参数。

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

如果您使用的是一个类别忘了进口flash.geom.Point;

问题回答

hitTestPoint()方法会让你的信息如果DisplayObject在指定点(< a href = " http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/DisplayObject.html hitTestPoint ()“rel = " nofollow noreferrer " > http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/DisplayObject.html hitTestPoint () < / >)

获得对象的列表会递归地调查所有儿童的阶段,我不认为有一个预定义的功能。

另外:你希望达到的目标是什么?也许你可以使用事件和使他们泡沫吗?





相关问题
热门标签