Simple TOUCHEVENT question (sliding off a button with multi-touch)

I’m working on a game where I want a player to be able to use arrow buttons and a jump (blue) button. I want the player to be able to slide their finger off and back on the arrows and also to be able to press the jump (blue) button while an arrow button is down. Here’s my listeners for the three buttons (gui[0], gui[1], and gui[3]):

gui[0].addEventListener(MouseEvent.MOUSE_DOWN, guiLeftDownHandler);
gui[0].addEventListener(MouseEvent.MOUSE_OUT, guiLeftUpHandler);	
gui[0].addEventListener(MouseEvent.MOUSE_UP, guiLeftUpHandler);	
gui[1].addEventListener(MouseEvent.MOUSE_DOWN, guiRightDownHandler);
gui[1].addEventListener(MouseEvent.MOUSE_OUT, guiRightUpHandler);	
gui[1].addEventListener(MouseEvent.MOUSE_UP, guiRightUpHandler);	

gui[3].addEventListener(MouseEvent.MOUSE_DOWN, guiJumpDownHandler);	

Multi touch does not seem to be working with this set-up. Anyone know why?


Try TouchEvent instead of MouseEvent.

Great. Oddly, a mixture of the two was the only thing that worked. Thanks Player_03!

	gui[0].addEventListener(TouchEvent.TOUCH_BEGIN, guiLeftDownHandler);
        gui[0].addEventListener(MouseEvent.MOUSE_OUT, guiLeftUpHandler);	
	gui[0].addEventListener(TouchEvent.TOUCH_END, guiLeftUpHandler);	
	gui[1].addEventListener(TouchEvent.TOUCH_BEGIN, guiRightDownHandler);
	gui[1].addEventListener(MouseEvent.MOUSE_OUT, guiRightUpHandler);	
	gui[1].addEventListener(TouchEvent.TOUCH_END, guiRightUpHandler);	
	gui[3].addEventListener(TouchEvent.TOUCH_BEGIN, guiJumpDownHandler);

I forget the exact difference, but there is also ROLL_OUT/ROLL_OVER in addition to MOUSE_OUT/MOUSE_OVER

As I understand it, the difference is that MOUSE_OVER bubbles.

This means that if the button has children, then it’ll get a MOUSE_OVER event each time any of those children gets one. And whenever a child gets a MOUSE_OUT event, that event will bubble up to the button itself, even if the mouse was over some other part of the button.

The easy solution is to use ROLL_OUT, but you can also set mouseChildren = false. That way, the children won’t receive events, so there won’t be any events bubbling up, so it won’t matter if you use MOUSE_OUT or ROLL_OUT. (This is nice if you forget which one is which.)