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
Retired
sylvester
Posts: 5
Registered: ‎11-17-2010
My Device: Not Specified
Accepted Solution

Gesture/touch support on the PB simulator under OS X?

Did anyone have any luck with gestures on the PlayBook simulator under OS X? Following Lee Brimelow's examples on multi-touch/gesture apps, I created and tested a simple gesture-driven shape/stage-pushing-sizing-rotating app published to AIR 2.5 Player, and it worked as expected in the native OS X environment on my Mac Book Pro, using its touchpad to fire gesture events.

 

When packaged and deployed the same AIR app to the simulator, all I'm getting is the single point/touch response, and gestures don't fire at all (other than invoking the built-in gestures with the mouse, such as calling up keyboard and other gestures as mentioned in one of the first two dev webcasts). Not sure whether this is OS X-to-VMware Fusion issue (ie gestures from the trackpad are not being passed to the virtual engine), or the PlayBook Simulator/API issue given its beta stage. Any help appreciated.

Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: Gesture/touch support on the PB simulator under OS X?

I recall someone else saying that multi-touch is not available in the simulator yet.

 

If your code is not large and your willing to share, I can verify it under Windows.

Retired
sylvester
Posts: 5
Registered: ‎11-17-2010
My Device: Not Specified

Re: Gesture/touch support on the PB simulator under OS X?

Sure thing John, thanks, below's the code - please give it a go on the Windows side. It's really Lee's example slightly expanded to support GESTURE_PAN and GESTURE_SWIPE in addition to stage/shape zoom/rotate. This was published from the Flash Pro, so the code refers to a simple box mc in the library, exported for ActionScript - alternatively you can drawRect the box.

 

 

import flash.display.StageDisplayState;
import flash.sampler.Sample;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.events.TransformGestureEvent;

Multitouch.inputMode = MultitouchInputMode.GESTURE;

stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.addEventListener(TransformGestureEvent.GESTURE_ZOOM, onStageZoom);
stage.addEventListener(TransformGestureEvent.GESTURE_ROTATE, onStageRotate);
stage.addEventListener(TransformGestureEvent.GESTURE_PAN, onStagePan);
stage.addEventListener(TransformGestureEvent.GESTURE_SWIPE, onStageSwipe);

var con:Sprite = new Sprite();
con.x = stage.stageWidth * 0.5;
con.y = stage.stageHeight * 0.5;
addChild(con);

for(var i:uint=0; i<10; i++)
{
	var b:Sprite = Sprite(new box());
	b.x = Math.random() * stage.stageWidth - (stage.stageWidth * 0.5);
	b.y = Math.random() * stage.stageHeight - (stage.stageHeight * 0.5);
	b.rotation = Math.random() * 360;
	b.addEventListener(MouseEvent.MOUSE_DOWN, onDown);
	b.addEventListener(MouseEvent.MOUSE_UP, onUp);
	b.addEventListener(TransformGestureEvent.GESTURE_ZOOM, onZoom);
	b.addEventListener(TransformGestureEvent.GESTURE_ROTATE, onRotate);
	con.addChild(b);

}

function onDown(e:MouseEvent):void
{
	var b:Sprite = Sprite(e.currentTarget);
	con.addChild(b);
	b.startDrag();
}

function onUp(e:MouseEvent):void
{
	var b:Sprite = Sprite(e.currentTarget);
	con.addChild(b);
	b.stopDrag();
}

function onZoom(e:TransformGestureEvent):void
{
	e.stopImmediatePropagation();
	var b:Sprite = Sprite(e.currentTarget);
	b.scaleX *= e.scaleX;
	b.scaleY = b.scaleX;
}

function onRotate(e:TransformGestureEvent):void
{
	e.stopImmediatePropagation();
	var b:Sprite = Sprite(e.currentTarget);
	b.rotation += e.rotation;
}

function onStagePan(e:TransformGestureEvent):void
{
	con.x += e.offsetX;
	con.y += e.offsetY;
}

function onStageSwipe(e:TransformGestureEvent):void
{
	con.x += e.offsetX*10;
	con.y += e.offsetY*10;
}

function onStageZoom(e:TransformGestureEvent):void
{
	con.scaleX *= e.scaleX;
	con.scaleY *= e.scaleY;
}

function onStageRotate(e:TransformGestureEvent):void
{
	con.rotation += e.rotation;
}

 

 

Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: Gesture/touch support on the PB simulator under OS X?

[ Edited ]

Worked fine under Windows AIR and Windows BB simulator.  Had to make some code adjustments to get it to compile and work.  See code below.  Since the simulator does not support gestures yet, I could only drag items around.

 

package
{

import flash.display.StageDisplayState;
import flash.sampler.Sample;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.events.TransformGestureEvent;
import flash.ui.MultitouchInputMode;
import flash.ui.Multitouch;
	

[SWF(height="600", width="1024", frameRate="30", backgroundColor="#000000")]
  public class Gesture extends Sprite
  {
	private var con:Sprite;
		
	////////////////////////////////////////////////////////////////
	public function Gesture()
	{
		Multitouch.inputMode = MultitouchInputMode.GESTURE;
			
		//stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
		//stage.scaleMode = StageScaleMode.NO_SCALE;
		//stage.align = StageAlign.TOP_LEFT;
		stage.addEventListener(TransformGestureEvent.GESTURE_ZOOM, onStageZoom);
		stage.addEventListener(TransformGestureEvent.GESTURE_ROTATE, onStageRotate);
		stage.addEventListener(TransformGestureEvent.GESTURE_PAN, onStagePan);
		stage.addEventListener(TransformGestureEvent.GESTURE_SWIPE, onStageSwipe);
			
		this.con = new Sprite();
		this.con.x = stage.stageWidth * 0.5;
		this.con.y = stage.stageHeight * 0.5;
		this.addChild( this.con );
			
		var b:Sprite;
			
		for(var i:uint=0; i<10; i++)
		{
			b = new Sprite();
				
			b.graphics.clear();
			b.graphics.beginFill( 0x00FF00, 1 );
			b.graphics.drawRect( 0, 0, 100, 100 );
			b.graphics.endFill();
			
			b.x = Math.random() * stage.stageWidth - (stage.stageWidth * 0.5);
			b.y = Math.random() * stage.stageHeight - (stage.stageHeight * 0.5);
			b.rotation = Math.random() * 360;
			b.addEventListener(MouseEvent.MOUSE_DOWN, onDown);
			b.addEventListener(MouseEvent.MOUSE_UP, onUp);
			b.addEventListener(TransformGestureEvent.GESTURE_ZOOM, onZoom);
			b.addEventListener(TransformGestureEvent.GESTURE_ROTATE, onRotate);
			this.con.addChild(b);
				
		}
			
		stage.nativeWindow.visible = true;
	}
		
		///////////////////////////////////////////////////////////
	private function onDown(e:MouseEvent):void
	{
		var b:Sprite = Sprite(e.currentTarget);
		this.con.addChild(b);
		b.startDrag();
	}
		
		////////////////////////////////////////////////////////////////
	private function onUp(e:MouseEvent):void
	{
		var b:Sprite = Sprite(e.currentTarget);
		this.con.addChild(b);
		b.stopDrag();
	}
		
		////////////////////////////////////////////////////////////////
	private function onZoom(e:TransformGestureEvent):void
	{
		e.stopImmediatePropagation();
		var b:Sprite = Sprite(e.currentTarget);
		b.scaleX *= e.scaleX;
		b.scaleY = b.scaleX;
	}
		
		////////////////////////////////////////////////////////////////
	private function onRotate(e:TransformGestureEvent):void
	{
		e.stopImmediatePropagation();
		var b:Sprite = Sprite(e.currentTarget);
		b.rotation += e.rotation;
	}
		
		////////////////////////////////////////////////////////////////
	private function onStagePan(e:TransformGestureEvent):void
	{
		this.con.x += e.offsetX;
		this.con.y += e.offsetY;
	}
		
		////////////////////////////////////////////////////////////////
	private function onStageSwipe(e:TransformGestureEvent):void
	{
		this.con.x += e.offsetX*10;
		this.con.y += e.offsetY*10;
	}
		
		///////////////////////////////////////////////////////////////
	private function onStageZoom(e:TransformGestureEvent):void
	{
		this.con.scaleX *= e.scaleX;
		this.con.scaleY *= e.scaleY;
	}
		
		////////////////////////////////////////////////////////////////
	private function onStageRotate(e:TransformGestureEvent):void
	{
	  this.con.rotation += e.rotation;
	}
  }
}

 

Retired
sylvester
Posts: 5
Registered: ‎11-17-2010
My Device: Not Specified

Re: Gesture/touch support on the PB simulator under OS X?

 


jtegen wrote:

....Since the simulator does not support gestures yet, I could only drag items around.

 


 

That's as far as I was getting too on the Mac side - out of curiosity, what method of physical input/hardware were you using for testing gestures on the Windows side?

 

As far as PB simulator not supporting the gestures yet, you seem to be sure about it per above, yet testing Multitouch.supportsGestureEvents and Multitouch.supportsTouchEvents on the simulator returns TRUE per snapshot below:

 

Screen shot 2010-11-18 at 11.42.46 AM.png

Can be verified by running this simple snippet through Flash Builder 4 and deploying to PlayBook simulator:

 

 

package
{
	import flash.display.Sprite;
	
	public class TestMultitouchSupport extends Sprite
	{
		public function TestMultitouchSupport()
		{
			import flash.ui.Multitouch;
			import flash.display.Sprite;
			import flash.text.TextField;
			import flash.text.TextFieldType;
			
			var label1:TextField = new TextField();
			label1.x = 50;
			label1.y = 100;
			label1.width = 200;
			label1.height = 25;
			label1.scaleX = label1.scaleY = 4;
			addChild(label1);
			
			var label2:TextField = new TextField();
			label2.x = 50;
			label2.y = 200;
			label2.width = 200;
			label2.height = 25;
			label2.scaleX = label2.scaleY = 4;
			addChild(label2);
			
			
			if (Multitouch.supportsGestureEvents)
			{
				label1.text ="gestureEvents work";
			} else {
				label1.text = "!gestureEvents";
			}
			
			if (Multitouch.supportsTouchEvents)
			{
				label2.text = "touchEvents work";
			} else {
				label2.text = "!touchEvents";
			}
		}
	}
}

I'm still not entirely convinced that the native-OS-to-WMware link is fully passing the gestures to the PB simulator; would be nice to hear some official comments from the simulator people regarding the in-application gesture support (as in, would be nice to be able to pinch-zoom images, rotate/pan the stage, and flick the squares just for fun :smileyhappy: - the touch/gestures are the primary input method on this device after all.

 

Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: Gesture/touch support on the PB simulator under OS X?

How would or how does a multi-touch system in VMWare respond from a single touch, mouse driven parent OS?  Some key combination while moving the mouse?

Retired
pbhattacherjee
Posts: 33
Registered: ‎08-07-2009
My Device: Not Specified

Re: Gesture/touch support on the PB simulator under OS X?

[ Edited ]

Hi Guys,

 

The gestures are not fully working quite yet, so that's why you're seeing the results that you are (in terms of only some things are doing anything).  The ones that we will have in the device include:

 

  • Swipe
  • Rotate
  • Pinch and Zoom
  • Pan
  • Press and Tap
And these will follow the standard AIR API's for gestures.
We're also working on a  good way to support multi touch from the simulator, we definitely understand the need for developers to test apps with multi touch.
Prosanta

 

New Developer
helliott
Posts: 8
Registered: ‎12-22-2010
My Device: Not Specified

Re: Gesture/touch support on the PB simulator under OS X?

has TransformGestureEvent.GESTURE_PAN and TransformGestureEvent.GESTURE_SWIPE in the latest SDK release 0.9.2?

It's " in the last place you looked" because you stopped looking.
Developer
JRab
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Gesture/touch support on the PB simulator under OS X?

hey,

 

the SDK already supports gestures and the API's to handle multi touch gestures. it will use the standard AIR API's. its just a matter of having the simulator support the testing. the current simulator does not support any multi-touch testing. hopefully it'l be available soon (or we have to wait till we get actual devices to test on). and when it does get released it'll be noted in the release notes. or even on the forums (would be a huge deal).

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
New Developer
helliott
Posts: 8
Registered: ‎12-22-2010
My Device: Not Specified

Re: Gesture/touch support on the PB simulator under OS X?

i should have been more specific as to the fact that i'm running vmware on a mac.

It's " in the last place you looked" because you stopped looking.