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

Supporting BlackBerry PlayBook, BlackBerry Z10 and/other screen resolutions for AIR by modifying the stage

by Developer on ‎06-04-2013 03:44 PM (3,075 Views)

If you want to support different screen resolutions with the same application, but keeping the game ratio, the easiest way is to directly modify the stage you're in. Let's say you created a game for BlackBerry® PlayBook™ with a resolution of 1024x600 and want it to run on the BlackBerry® Z10 with a resolution of 1280x768. But due to several reasons (time, money, etc.) you can't redo it from scratch. Take a look at the following code which scales up your app up to fit in width on both PlayBook and Z10

 

package
{
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.system.Capabilities;
	import flash.ui.Mouse;
	
	[SWF(width='1024', height='600', backgroundColor='#000000', frameRate='60')]
	public class MyScreenResolutions extends Sprite
	{
//if you should ever need the scale, you can read it from this static var public static var GAMESCALE:Number = 1.0; public function MyScreenResolutions () { stage.align = ""; stage.scaleMode = StageScaleMode.NO_SCALE; GAMESCALE = stage.stageWidth / 1024; this.scaleX = GAMESCALE; this.scaleY = GAMESCALE;
//do stuff super(); } } }

Since all Adobe® Flash® applications run on a stage, you can access it directly from each Sprite. Therefore you can scale it up according to your needs, make it larger, wider, squared.

The additional macro [SWF(width='1024', height='600'] is just for a default size

 

As additional hint: obviously, the ratio 1024/600 is not equal to 1280/768. You will remain with a few pixels left in height. In this example, nothing is done except setting the backgroundColor to black in the macro. Of course, you could also add additional components or functionalities, like an energy bar in your game, or tabs and shortcuts in others.

 

It's worth noting that aspect ratios on BlackBerry devices have been standardized going forward to 16:9 and 1:1. If you're going to be creating a game or application you should consider these aspect ratios. More information can be found in this announcement - http://devblog.blackberry.com/2012/08/blackberry-10-screen-resolutions/

Contributors
Users Online
Currently online: 25 members 1,998 guests
Please welcome our newest community members: