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
Developer
ChappyK
Posts: 75
Registered: ‎09-13-2011
My Device: Playbook
Accepted Solution

BB10 Orientation Switching

Hey everyone, I've looked around and found nothing of the sort that was helpful. Basically I'm migrating my Playbook app to BB10 but I'm having issues with orientation switching. On the playbook I've used stage.setOrientation(StageOrientation.DEFAULT); and stage.setOrientation(StageOrientation.ROTATED_RIGHT); and it worked great for the playbook but on the BB10 this seems to not work at all. <autoOrients>false</autoOrients> this setting has been the same for both devices.

 

Thanks in andvance and Happy Holidays to all



Show your support and click on the like button when you see a post that was helpful.
Retired
dmalik
Posts: 427
Registered: ‎02-22-2012
My Device: BlackBerry Z10, BlackBerry Dev Alpha C, BlackBerry PlayBook

Re: BB10 Orientation Switching

Hi,

 

Are you trying to keep your orientation in the landscape layout?

 

Regards,

Dustin

Follow me on Twitter: @dustinmalik
-----------------------------------------------------------------------------------------------------
Keep up to date on BlackBerry development: http://devblog.blackberry.com/
Developer
ChappyK
Posts: 75
Registered: ‎09-13-2011
My Device: Playbook

Re: BB10 Orientation Switching

I launch the app in landscape by default but I let the user choose landscape or portrait before pushing the next view. so far it stays line landscape but portrait assets are being loaded so I know the right code is running.


Show your support and click on the like button when you see a post that was helpful.
Retired
dmalik
Posts: 427
Registered: ‎02-22-2012
My Device: BlackBerry Z10, BlackBerry Dev Alpha C, BlackBerry PlayBook

Re: BB10 Orientation Switching

Here is some code on how I handle portrait/landscape.

 

package
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	
	[SWF(frameRate="60", backgroundColor="#00FF00")]
	public class DisplayTest extends Sprite
	{
		private var container:Container;
		private var image:Image;
		
		public function DisplayTest()
		{
			
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			addEventListener(Event.ADDED_TO_STAGE,handleAddedToStage);
			
		}
		
		private function handleAddedToStage(e:Event):void
		{
			removeEventListener(Event.ADDED_TO_STAGE,handleAddedToStage);
			
			// stage is avail, we can now listen for events
			stage.addEventListener( Event.RESIZE, onResize );
			
			// force a resize call
			onResize(new Event(Event.RESIZE));
		}

		
		private function onResize(event:Event):void
		{
			
			//portrait
			if ( stage.stageHeight > stage.stageWidth ) {
				
				trace("portrait mode");
				container.width = stage.stageWidth;
				container.height = stage.stageHeight;
				
				
			//landscape
			}else{
				trace("landscape mode");
				container.width = stage.stageWidth;
				container.height = stage.stageHeight;
				
			}
			
		}
	}
}

 

Follow me on Twitter: @dustinmalik
-----------------------------------------------------------------------------------------------------
Keep up to date on BlackBerry development: http://devblog.blackberry.com/
Developer
ChappyK
Posts: 75
Registered: ‎09-13-2011
My Device: Playbook

Re: BB10 Orientation Switching

Though this solution does solve some of the issues it doesn't really change the orientation. I have a qnx swipe down event for a toolbar at the top of the screen that needs to always be at the top of the current orientation setting.

I seem to have solved my problem by using stage.setAspectRatio(StageAspectRatio.PORTRAIT);
stage.setAspectRatio(StageAspectRatio.LANDSCAPE); along with my current code.


Show your support and click on the like button when you see a post that was helpful.