I have Sprite object that is a poker chip. When the user clicks it the bid increase. I am increasing the bid on the MouseUp event. But if the user starts a click outside of the object/chip and then drags the mouse over the chip and does MouseUp, it fires the function mapped to MouseUp. How can I prevent it from firing if the click starts outside of the object.
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)
}
}
Thanks
On roll over, start listening to mouse down and mouse up, if up before down, it’s a “fake”
this.addeventlistener(MouseEvent.ROLL_OVER, onOver)
…