03-02-2011 02:27 PM
Hey guys,
I have a project where i have a canvas which you can draw onto and a sidebar where you select tools to draw with. It's a very simple application
What want to do it when the tablet is rotated 90 degrees, i want the canvas not to rotate but i want the bar to follow the rotation if that makes sense.
So the bar should always be on the left, but the canvas should be in a fixed position
The canvas is an AS3 Sprite and the bar and controls are flex components
How could i do this?
Thanks
Chris
03-02-2011 02:39 PM - edited 03-02-2011 02:40 PM
As per: http://docs.blackberry.com/en/developers/deliverab
Code sample: Detecting a rotation gesture event
package
{
import flash.display.Sprite;
import flash.events.TransformGestureEvent;
import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode
[SWF(width="1024", height="600", backgroundColor="#cccccc", frameRate="30")]
public class RotateDemo extends Sprite
{
private var _rotateMe:Sprite = new Sprite();
public function RotateDemo()
{
Multitouch.inputMode = MultitouchInputMode.GESTURE;
_rotateMe.graphics.lineStyle(1,0x83A603);
_rotateMe.graphics.beginFill(0xE9D303);
_rotateMe.graphics.drawRoundRect(0,0,100,100,20);
_rotateMe.graphics.endFill();
_rotateMe.x = (stage.stageWidth - rotateMe.width) /2;
_rotateMe.y = (stage.stageHeight - rotateMe.height) /2;
addChild(rotateMe);
rotateMe.addEventListener( TransformGestureEvent.GESTURE_ROTATE, onRotate );
}
public function onRotate(event:TransformGestureEvent):void
{
_rotateMe.rotation += event.rotation;
}
}
}Code sample: Detecting an orientation change event
package
{
import flash.display.Sprite;
import flash.events.AccelerometerEvent;
import flash.sensors.Accelerometer;
import qnx.ui.text.Label;
[SWF(width="1024", height="600", backgroundColor="#cccccc", frameRate="30")]
public class OrientationDemo extends Sprite
{
private var lblStatus:Label = new Label();
public function OrientationDemo()
{
lblStatus.width = stage.stageWidth;
addChild(lblStatus);
var accel:Accelerometer = new Accelerometer();
accel.addEventListener(AccelerometerEvent.UPDATE, onUpdate);
}
private function onUpdate(event:AccelerometerEvent):void
{
var strStatus:String;
if( event.accelerationX > 0.5 )
{
strStatus = "Device orientation: Left side up";
}
else if( event.accelerationX < -0.5 )
{
strStatus = "Device orientation: Right side up";
}
else if( event.accelerationY > 0.5 )
{
strStatus = "Device orientation: Standing";
}
else if( event.accelerationY < -0.5 )
{
strStatus = "Device orientation: Standing upside down";
}
else if( event.accelerationZ > 0.5 )
{
strStatus = "Device orientation: Face up";
}
else if( event.accelerationZ < -0.5 )
{
strStatus = "Device orientation: Face down";
}
lblStatus.text = strStatus;
}
}
}
09-18-2011 01:37 PM
Oh im excited I just noticed the new dev guide thx to this post. KUDOS for making me aware!
09-18-2011 02:07 PM