单击从对象外部开始时阻止MouseUp

时间:2012-08-03 05:46:22

标签: events actionscript mouseevent

我有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)
        }
    }

由于

1 个答案:

答案 0 :(得分:1)

滚动时,开始聆听鼠标按下并向上鼠标按下,如果向下按下,则为“假”

this.addeventlistener(MouseEvent.ROLL_OVER,onOver)

...