Adobe AIR bordered window creates a stage for the wrong size

I set up OpenFL to create an app with a stage size of 1280 x 720.

<window width="1280" height="720" unless="mobile" resizable="false" borderless="false" />

When I test the SWF export for Flash Player, the stageWidth and stageHeight read 1280 x 720.

But when I test it as an AIR app, the stageWidth and stageHeight read as 1264 x 681 when the “borderless” attribute is set to “false” in the project xml.

If I set the “borderless” attribute to “true”, the stageWidth and stageHeight go back to 1280 x 720.

I tested using the latest AIR SDK, but I have a feeling this behavior changed, at least on Windows.

After reading your post, I added the following code to my ApplicationMain

if (::WIN_WIDTH:: != 0 && ::WIN_HEIGHT:: != 0) {
	var stage = app.window.stage;
	trace (stage.stageWidth);
	trace (stage.stageHeight);
	stage.nativeWindow.width = ::WIN_WIDTH:: + (::WIN_WIDTH:: - stage.stageWidth);
	stage.nativeWindow.height = ::WIN_HEIGHT:: + (::WIN_HEIGHT:: - stage.stageWidth);
	trace (stage.stageWidth);
	trace (stage.stageHeight);

It first traced 800 x 600 as the stage size, but then it shrunk after I resized it.

EDIT: The upcoming Lime version does not try to create an initial Window on AIR, because the window will already be created. Perhaps this is why it appears to be working now, because setting nativeWindow.width = 800 and nativeWindow.height = 600 will give us a smaller size

EDIT2: I explored a little more, it appears that the first time nativeWindow width/height are set, it sets it to a stageWidth/stageHeight of the requested size (at least here on the latest AIR with Windows) but subsequent requests will make the native window that size, and the stage width and height will be accordingly smaller.

I think after the fact, this could be fixed by bumping the nativeWindow up to a larger size, but I think I should have this resolved for the next release of Lime (it’s a major breaking release, though, so working around might be simpler at the moment)

1 Like