Reputation: 3828
I am trying to set my mc to the exact screen size on an iPhone using air in as3.
I have tired:
import flash.display.Screen;
import flash.geom.Rectangle;
var mainScreen:Screen = Screen.mainScreen;
var screenBounds:Rectangle = mainScreen.bounds;
/// Does not work - comes out 320 by 480
w.text = ""+screenBounds.width+"";
h.text = ""+screenBounds.height+"";
BG.height = screenBounds.height;
BG.width = screenBounds.width;
/// Does not work - comes out 320 by 480
w.text = ""+Capabilities.screenResolutionX+"";
h.text = ""+Capabilities.screenResolutionY+"";
BG.height = Capabilities.screenResolutionY;
BG.width = Capabilities.screenResolutionX;
/// Does not work - comes out 320 by 480
w.text = ""+stage.fullScreenwidth+"";
h.text = ""+stage.fullScreenHeight+"";
BG.height = stage.fullScreenHeight;
BG.width = stage.fullScreenWidth;
/// Works BUT... it does NOT stretch to fit the stage.
/// I am starting with android screen size and it shrinks it proportionally
/// which means there is space on top or bottom or left side.
w.text = ""+stage.stageWidth+"";
h.text = ""+stage.stageHeight+"";
BG.height = stage.stageHeight;
BG.width= stage.stageWidth;
Upvotes: 0
Views: 7994
Reputation: 69
if someone else is having issues getting the screen resolution for ios. What is happening is that there is no enough time between the completed loaded swf and the time you call the screen size.
For my app I need the swf with no scale because I am setting all my clips size and positions by setting a relative value to screen size in percent.
if my stage is 800x1280 and I have a clip with height = 100, width = 100;
then is the same to say that my clips.height = int(stage.stageWidth * 0.125); as 100 * 100 / 800 = 12.5; | 100 is the 12.5% from 800;
The trick is that for your first frame (if you are using flash)
just set the stage scale and wait for full load the swf, and just that.
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
var loadTimer:Timer = new Timer(10);
loadTimer.addEventListener(TimerEvent.TIMER, loading);
loadTimer.start();
function loading(evt){
if(root.loaderInfo.bytesLoaded == root.loaderInfo.bytesTotal){
loadTimer.stop();
loadTimer.removeEventListener(TimerEvent.TIMER, loading);
gotoAndPlay(2);
}
}
then in the frame 2 you can call the stage.stageWidth and it will give you the real size, as you have give enough time to the app get that value.
var stageW:int = stage.stageWidth;
var stageH:int = stage.stageHeight;
I hope it can help, thanks
Upvotes: 1
Reputation: 1476
Here is a detailed explanation:
http://www.adobe.com/devnet/air/articles/multiple-screen-sizes.html
Upvotes: 1
Reputation: 8159
If it is coming out 320x480 and you are saying that is wrong, can I assume you are using an iPhone 4S? If so, go into the App Descriptor XML file. Toward the bottom (generally one of the last items in the file), there should be this line.
<requestedDisplayResolution>standard</requestedDisplayResolution>
If it is commented out or set to "standard", this would be your issue. Change it to say "high" and that will enable Retina support. "standard" scales the non-retina display (320x480 on iPhone, 1024x768 on iPad) up. "high" will give you the correct display resolution.
Upvotes: 1
Reputation: 13532
You can try to play around with stage.scaleMode :
stage.scaleMode = StageScaleMode.SHOW_ALL;
or
stage.scaleMode = StageScaleMode.EXACT_FIT;
Upvotes: 1