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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Adobe AIR Development

Reply
Regular Contributor
chriswillis10
Posts: 62
Registered: ‎12-21-2010

Setting orientation properties

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

Please use plain text.
Developer
ahazdesigns
Posts: 152
Registered: ‎08-25-2010
My Carrier: Verizon

Re: Setting orientation properties

[ Edited ]

As per: http://docs.blackberry.com/en/developers/deliverables/23959/Responding_to_events_1425036_11.jsp

 

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;
        }

    }
}

 

 

 

Please use plain text.
Regular Contributor
MindOperations
Posts: 64
Registered: ‎03-04-2010
My Carrier: VZN

Re: Setting orientation properties

Oh im excited I just noticed the new dev guide thx to this post.  KUDOS for making me aware!

Brandon Clark
The Mind Company | www.themindspot.com

Please use plain text.
Regular Contributor
MindOperations
Posts: 64
Registered: ‎03-04-2010
My Carrier: VZN

Re: Setting orientation properties

Very good help and example.
Brandon Clark
The Mind Company | www.themindspot.com

Please use plain text.