Skip to main content
Inspiring
December 30, 2013
Answered

Wrong stage size on MBP Retina

  • December 30, 2013
  • 1 reply
  • 1934 views

Hi, i'm not sure if it's a bug or i'm doing something wrong, but i don't get the right stage bounds on my Macbook Pro Retina.

I already set <requestedDisplayResolution>high</requestedDisplayResolution> inside the  initialWindow tag, but stage.fullScreenWidth returns always 1440 instead of 2880 and stage.stageWidth returns wrong values also.

I made tests with AIR SDKs 3.7, 3.8, 3.9 and 4.0, but no one worked for me.
Am i overlooking something?

Here's the code i'm using:

package
{
     import flash.display.Sprite;
     import flash.display.StageAlign;
     import flash.display.StageScaleMode;
     import flash.events.Event;
     import flash.text.TextField;
     import flash.text.TextFormat;

     public class Test extends Sprite
     {
          private var console : TextField;
          public function Test()
          {
               stage.scaleMode = StageScaleMode.NO_SCALE;
               stage.align = StageAlign.TOP_LEFT;
               stage.addEventListener(Event.RESIZE, onStageResize);
               
               console = new TextField();
               console.defaultTextFormat = new TextFormat("_sans", 12);
               console.width = stage.stageWidth;
               console.height = stage.stageHeight;
               console.wordWrap = true;
               console.multiline = true;
               addChild(console);
          }

          private function onStageResize(event : Event) : void
          {
               output("***********************************************");
               output('stage.contentsScaleFactor: ' + (stage.contentsScaleFactor));
               output('stage.stageWidth: ' + (stage.stageWidth));
               output('stage.stageHeight: ' + (stage.stageHeight));
               output('stage.fullScreenWidth: ' + (stage.fullScreenWidth));
               output('stage.fullScreenHeight: ' + (stage.fullScreenHeight));
               
               console.width = stage.stageWidth;
               console.height = stage.stageHeight;
          }

          private function output(... $text) : void
          {
               var text:String = $text.join(", ");
               console.appendText(text+"\n");
               trace(text);
          }
     }
}

Thanks in advance,
Solano

This topic has been closed for replies.
Correct answer jadams602

I believe this is the expected behavior on the native stage. Even when running on a retina device with requestedDisplayResolution set to high, the native stage uses the same coordinate system as the non-retina version, and stageWidth and stageHeight are reported with the same units, as mentioned in the docs for contentsScaleFactor:

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Stage.html#contentsScaleFactor

You could query the value of contentsScaleFactor to know if running in retina mode or not.

The native stage coordinates stay the same, but if you are using Stage3D in your app, the higher res back buffer is created with another additonal argument to configureBackBuffer():

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display3D/Context3D.html#configureBackBuffer%28%29

and in this case the raw pixel dimensions would be double in size.

1 reply

jadams602
jadams602Correct answer
Inspiring
January 1, 2014

I believe this is the expected behavior on the native stage. Even when running on a retina device with requestedDisplayResolution set to high, the native stage uses the same coordinate system as the non-retina version, and stageWidth and stageHeight are reported with the same units, as mentioned in the docs for contentsScaleFactor:

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Stage.html#contentsScaleFactor

You could query the value of contentsScaleFactor to know if running in retina mode or not.

The native stage coordinates stay the same, but if you are using Stage3D in your app, the higher res back buffer is created with another additonal argument to configureBackBuffer():

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display3D/Context3D.html#configureBackBuffer%28%29

and in this case the raw pixel dimensions would be double in size.

Inspiring
January 2, 2014

Thank you Jeffrey for your help. Actually you helped me a lot inderectly with your posts in the Starling forum.

If I have understood correctly, I can reproduce in Stage3D a highres image but not target every single pixel.

So when I display an image with a width of 200px and want to align another image on the right side, I have to align the second image with x = 100? This is really confusing.

Will do some tests now and come back here. What I've noticed, is that it doesn't matter if I set the flag requestedDisplayResolution to high or not. The conentScaleFactor will return always 2. I'm wondering for what we have this flag.

Best Regards and a happy new Year,

Solano

Inspiring
January 2, 2014

Ok, I got it now. I was confused, because all images were scaled up, although I used the scale factor 1. Since Flash wont work with the real bounds, all textures have to be scaled down. And this did the trick.

Thank you very much Jeffrey