If you are using Internet Explorer, please remove blackberry.com from your compatibility view settings.

Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Contributor
varliali
Posts: 14
Registered: ‎03-11-2013
My Device: Dev Alpha B
My Carrier: Vodafone
Accepted Solution

Swipe gesture fires multiple times

I have implemented swipe gesture as explained in this blog http://developer.blackberry.com/air/documentation/bb10/detecting_a_swipe_gesture.html

 

My problem is that when I deploy it to the device (Dev Alpha B) the event fires more than one time (generally 2 or 3 times) although I swipe only once.

Please use plain text.
Developer
shaan_softwaredvlpr
Posts: 172
Registered: ‎01-17-2011
My Device: 9500 series
My Carrier: Airtel

Re: Swipe gesture fires multiple times

Are you having one screen , or more than one screen in your app.
Remember to remove listeners before leaving this class to another class.
Please use plain text.
Contributor
varliali
Posts: 14
Registered: ‎03-11-2013
My Device: Dev Alpha B
My Carrier: Vodafone

Re: Swipe gesture fires multiple times

I checked it. With gesture simulator it works as intended but the problem is when deployed to the device.

Please use plain text.
Contributor
varliali
Posts: 14
Registered: ‎03-11-2013
My Device: Dev Alpha B
My Carrier: Vodafone

Re: Swipe gesture fires multiple times

Same problem with another game also. Any ideas?

Please use plain text.
Developer
SangramPatil
Posts: 271
Registered: ‎01-21-2013
My Device: BB10 Dev Aplha
My Carrier: -

Re: Swipe gesture fires multiple times

I also have used the same Swipe Gesture but it works fine on my Dev Alpha.

Please use plain text.
Developer
shaan_softwaredvlpr
Posts: 172
Registered: ‎01-17-2011
My Device: 9500 series
My Carrier: Airtel

Re: Swipe gesture fires multiple times

Can you please share your written code ?
Please use plain text.
Contributor
varliali
Posts: 14
Registered: ‎03-11-2013
My Device: Dev Alpha B
My Carrier: Vodafone

Re: Swipe gesture fires multiple times

loadlevel(l);
stage.addEventListener(KeyboardEvent.KEY_UP, kb_event);
stage.addEventListener(TransformGestureEvent.GESTURE_SWIPE, onSwipe);

public function onSwipe (e:TransformGestureEvent):void {
	if (e.offsetX == 1) { //right
		wMove(1,0);
	}
	if (e.offsetX == -1) { //left
		wMove(-1,0);
	} 
	if (e.offsetY == 1) { //down
		wMove(0,1);
	}
	if (e.offsetY == -1) { //up
		wMove(0,-1);
	}
}

 

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Swipe gesture fires multiple times

Gesture would fire more than once since your finger would still be moving. You will probably need to keep some "last state" so you only act on when the gesture changes directions and not an event of the gesture in the same direction. This is similar to a mouse move event.
Please use plain text.
Contributor
varliali
Posts: 14
Registered: ‎03-11-2013
My Device: Dev Alpha B
My Carrier: Vodafone

Re: Swipe gesture fires multiple times

jtgen, thank you for your answer. I think that is the reason but I didn't expect this behaviour.

On Androids and iOS it functions as expected. A swipe should not be fired continuously but only once because it is a single action. I think there should be a proper way to handle swipe event.

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Swipe gesture fires multiple times

I've learned that not everything works as planned. Most of the effort of programming is to work around problems. Adding a previous state member variable would still work on single fire systems.
Please use plain text.