11-17-2010 02:13 PM
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.
Solved! Go to Solution.
11-17-2010 02:23 PM
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.
11-17-2010 02:47 PM
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.GESTU RE_ROTATE, onStageRotate); stage.addEventListener(TransformGestureEvent.GESTU RE_PAN, onStagePan); stage.addEventListener(TransformGestureEvent.GESTU RE_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_Z OOM, onZoom); b.addEventListener(TransformGestureEvent.GESTURE_R OTATE, 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; }
11-17-2010 07:43 PM - edited 11-17-2010 07:44 PM
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.GESTU RE_ZOOM, onStageZoom);
stage.addEventListener(TransformGestureEvent.GESTU RE_ROTATE, onStageRotate);
stage.addEventListener(TransformGestureEvent.GESTU RE_PAN, onStagePan);
stage.addEventListener(TransformGestureEvent.GESTU RE_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_Z OOM, onZoom);
b.addEventListener(TransformGestureEvent.GESTURE_R OTATE, 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;
}
}
}
11-18-2010 11:53 AM
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:
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
- the touch/gestures are the primary input method on this device after all.
11-18-2010 11:59 AM
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?
11-18-2010 12:25 PM - edited 11-18-2010 12:25 PM
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:
01-18-2011 08:11 PM
has TransformGestureEvent.GESTURE_PAN and TransformGestureEvent.GESTURE_SWIPE in the latest SDK release 0.9.2?
01-18-2011 08:17 PM
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).
01-18-2011 09:31 PM
i should have been more specific as to the fact that i'm running vmware on a mac.