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
Regular Contributor
Posts: 51
Registered: ‎02-02-2011
My Device: Not Specified

Orientation Changes causes Scaling/Stretching

Hey all,

 

Hoping you guys can shed some light on this for me.  I am new to the Playbook SDK, but a seasoned flash developer.

 

I created an extremely simple app, when I change the orientation of the simulator, the app gets scaled.

 

I have set stage.scaleMode = StageScaleMode.NO_SCALE but it doesn't seem to matter.

 

I have read what I believe is every post in this forum remotely related to this issue with no success.

 

Here is a screenshot of the simulator in portrait mode - everything looks fine:

 

In Landscape

 

 

Here is a screenshot after I re-orient the simulator into Portrait mode - clearly the button the stretched and looks absurd:

 

portrait.jpg

 

 

Here is the extremely simple, cut down to the bare minimum, code:

 

 

package
{
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageQuality;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.events.StageOrientationEvent;
	
	import qnx.ui.buttons.LabelButton;
	import qnx.ui.core.Container;
	import qnx.ui.core.ContainerFlow;
	
	[SWF(height="600", width="1024", frameRate="30", backgroundColor="#cccccc")]
	public class PBMVPTest2 extends Sprite
	{
		private var _mainContainer:Container;
		private var _btn:LabelButton;
		
		public function PBMVPTest2()
		{
			this.addEventListener( Event.ADDED_TO_STAGE, handleAddedToStage );
			init();
		}

		private function handleAddedToStage( e:Event ):void
		{
			this.removeEventListener( Event.ADDED_TO_STAGE, handleAddedToStage );
			
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.quality = StageQuality.BEST;
			stage.nativeWindow.visible = true;
		}

		private function init():void
		{
			_mainContainer = new Container();
			_mainContainer.debugColor = 0xFFCC00;
			_mainContainer.margins = Vector.([20,20,20,20]);
			_mainContainer.flow = ContainerFlow.HORIZONTAL;
			this.addChild( _mainContainer );
			
			_btn = new LabelButton();
			_btn.label = "Some Button";
			_mainContainer.addChild( _btn );
		}
	}
}

 

Any help / advice would be appreciated, thank you!

Regular Contributor
Posts: 51
Registered: ‎02-02-2011
My Device: Not Specified

Re: Orientation Changes causes Scaling/Stretching

Also, is there some reason my container is not shown with the debug coloured margins???

Did they remove that in the newest simulator (I am using 0.9.2).

 

Cheers

Highlighted
Contributor
Posts: 23
Registered: ‎01-19-2011
My Device: Not Specified

Re: Orientation Changes causes Scaling/Stretching

Debug margins are still there, this is the code I use and it works for me

 

base.margins = Vector.<Number>([20,20,20,20]);

 

As for your other problem, I don't know. I started off using the qnx libraries, but had problems with the label control, so I switched to using a standard flex mobile application which can also be run on Android.

Regular Contributor
Posts: 51
Registered: ‎02-02-2011
My Device: Not Specified

Re: Orientation Changes causes Scaling/Stretching

[ Edited ]

I had the same Vector line as you, this forum just removed the "Number" portion.

 

So I don't get the margins, and I get this stupid scaling.  Argh!

 

 

PS - I am using SDK 0.9.2 with simulator 0.9.2 and have installed into Flash Builder 4.0.1 Professional.

Developer
Posts: 439
Registered: ‎10-25-2010
My Device: Not Specified

Re: Orientation Changes causes Scaling/Stretching

You need to remove the aspectRatio tag from your app-xml file, this will fix the weird stretching.

Regular Contributor
Posts: 51
Registered: ‎02-02-2011
My Device: Not Specified

Re: Orientation Changes causes Scaling/Stretching

My AIR blah-app.xml file does not have any such tag, nor does the blackberry-tablet.xml file.

 

Any other suggestions?

Developer
Posts: 1,003
Registered: ‎01-16-2011
My Device: PlayBook (sim)
My Carrier: Rogers

Re: Orientation Changes causes Scaling/Stretching

[ Edited ]

In your "blah-app.xml" file, expand "initial window". It should be listed under their. If it isn't, I would add it and then set it to...(thinking on this one)....true? no false! I'm actually not sure, maybe just try both?

 

EDIT: Wait, I may be off my rocker on this one (I haven't really done much coding this week). Perhaps someone else can weigh in lol

- If you like my response/post, or it helped you find an answer you were looking for, please provide a Kudo - white star to the bottom right of this post. -
- Please use the search bar at the top, or check out the PlayBook FAQ's for help getting started -
- Hockey DrillBook -
Regular Contributor
Posts: 51
Registered: ‎02-02-2011
My Device: Not Specified

Re: Orientation Changes causes Scaling/Stretching

Yeah, I checked under the initialWindow tag, it's not there.

 

If I add it and set it to true, it has no effect.  I don't believe true is a valid option there though, honestly, but, it's hard to say since there are no decent references!

Developer
Posts: 382
Registered: ‎05-19-2008
My Device: BlackBerry Torch
My Carrier: AT&T

Re: Orientation Changes causes Scaling/Stretching

Are you SURE you are using the 0.9.2 SDK? Really SURE? That was something I saw when I was using the 0.9.1 sdk with the 0.9.2 simulator. I also never got the orientation change events to fire, no matter what happened. Once I did finally figure out how to change the orientation in the simulator, it just stretched the screen.

 

Bill

 

 

Bill
-------------------------------------------
Check out my book on BlackBerry Development for Java.
And my other really really old book
My Apps: FlashKids
Developer
Posts: 1,003
Registered: ‎01-16-2011
My Device: PlayBook (sim)
My Carrier: Rogers

Re: Orientation Changes causes Scaling/Stretching

That's a good point actually. I installed the 0.9.2 SDK, and it was listed as the only one installed, but how would one check if they're evening using it? (I had started my app with 0.9.1, and couldn't find anything that detailed how to change to the newest environment)

- If you like my response/post, or it helped you find an answer you were looking for, please provide a Kudo - white star to the bottom right of this post. -
- Please use the search bar at the top, or check out the PlayBook FAQ's for help getting started -
- Hockey DrillBook -