我有 Sprite 对象,它是一个扑克筹码。当用户点击它时,出价会增加。我正在提高对MouseUp
活动的出价。但是,如果用户在对象/芯片之外开始单击,然后将鼠标拖到芯片上并执行此操作MouseUp
,它会触发映射到的函数MouseUp
。如果单击从对象外部开始,如何防止它触发。
this.addEventListener(MouseEvent.MOUSE_DOWN, pressChipDown)
this.addEventListener(MouseEvent.MOUSE_UP, pressChipUp)
this.addEventListener(MouseEvent.MOUSE_OUT, pressChipOut)
private function pressChipDown(e:MouseEvent):void
{
super.x = startX + 5;
super.y = startY + 5;
}
private function pressChipUp(e:MouseEvent):void
{
increaseBid();
super.x = startX;
super.y = startY;
}
private function pressChipOut(e:MouseEvent):void
{
if(e.buttonDown) //if mouse button is down, move chip back but dont increase bid
{
pressChipUp(MouseEvent.MOUSE_OUT as MouseEvent)
}
}
谢谢