侦听碰撞 object.hitTestPoint(stage.mouseX,stage.mouseY,false);
public function DialogTest() {
anima.mouseChildren = true;
anima.mouseEnabled = true;
addEventListener(MouseEvent.CLICK,ontest);
}
protected function ontest(event:MouseEvent):void
{
trace(event.localX,event.localY);
trace(event.stageX,event.stageY);
trace(stage.mouseX,stage.mouseY);
trace(mouseX,mouseY);
}
注意mouseX 和 mouseY 是相对于目标对象的。
而stage.mouseX 和 event.stageX 都是全局坐标,但是number 和int的区别
另外要注意的是 hitTestPoint 的第三个参数是是否实际像素碰撞。
BitmapData.hitTest(
firstPoint:Point,
firstAlphaThreshold:uint, secondObject:Object, secondBitmapDataPoint:Point = null,
secondAlphaThreshold:uint = 1)
此函数中检测的是bitmapData ,跟舞台上显示的bitmap不相干。