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
xvart
Posts: 34
Registered: ‎05-30-2012
My Device: playbook developer

Multitouch implementation in PlayBook

[ Edited ]

Hi,

 

So I need to have the user be able press 2 buttons/objects at the same time. It is a game controller: one to look around and one to walk around.

 

I know that we still (or at least could) can not check this through the emulator but I am using the tablet for debugging and I still can not get it working.

 

I have this line as the first line of my main:

Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

 

 

And my buttons have these lines:

MyButton.addEventListener(TouchEvent.TOUCH_TAP, MyFunction);

 

 

The function is defined as:

private function MyFunction(event:TouchEvent):void
		{
			//Do something
		}

 

Yet, I still can not press two of them at the same time. I must also add that there are also mouse-based buttons in the app. Any input is more than welcome.

Please use plain text.
Developer
pyth
Posts: 506
Registered: ‎01-19-2011
My Device: My Trusty Red Plane

Re: Multitouch implementation in PlayBook

I use multitouch in several of my apps, and it works fine. Though the only things I do are as following:

 

Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
            stage.addEventListener(TouchEvent.TOUCH_BEGIN, onTouchBegin);
            stage.addEventListener(TouchEvent.TOUCH_TAP, onTouchTap);
            stage.addEventListener(TouchEvent.TOUCH_END, onTouchEnd);

 

I don't add the touchevent to specific elements, I add them to the stage (performance is ok, running in gpu mode)

In my event handler, I additionally need to read event.stageX and event.stageY to get the correct coordinates. Then I take my elements and check if they were in the touched zone(s)

-----------------------------------------------------------------------
I'm a bird from outer space. But I'm not flappy o.o
Please use plain text.
Contributor
xvart
Posts: 34
Registered: ‎05-30-2012
My Device: playbook developer

Re: Multitouch implementation in PlayBook

Hmm never thought of adding event listener to the whole stage... I wonder if it makes the difference.

 

I also have TOUCH_BEGIN,TOUCH_MOVE, TOUCH_END and TOUCH_OUT they work as they should with a single finger...

Please use plain text.
Developer
KermEd
Posts: 175
Registered: ‎05-18-2009
My Device: NA

Re: Multitouch implementation in PlayBook

[ Edited ]

On the PlayBook I used them on Objects as well without an issue.

 

I saw a lot of good iOS tutorials on YouTube for AS3 + Multitouch that also work on QNX if you need some code examples.

 

Edit:. I used tbese when first starting on multitouch and PB.

Please use plain text.
Contributor
xvart
Posts: 34
Registered: ‎05-30-2012
My Device: playbook developer

Re: Multitouch implementation in PlayBook

I did not have time to transfer everything to stage but I will check the iOS tutorials. Also thanks for letting me know that it works on the objects as well (as it should).
Please use plain text.
Contributor
xvart
Posts: 34
Registered: ‎05-30-2012
My Device: playbook developer

Re: Multitouch implementation in PlayBook

After rewriting the app without objects I realized that I had written the code such that whenever a button is pressed the values that other buttons are sending become 0... So multitouch has been working..

Please use plain text.