my application starts with a scene size of 1000 x 500, the aspect ratio is 2: 1. its own window has a system chrome, which will always be slightly higher by a few pixels.
how can only proportional changes of the own window be allowed to always maintain a 2: 1 aspect ratio at the stage?
The following code does not work as I expect:
package
{
import flash.display.NativeWindow;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.NativeWindowBoundsEvent;
[SWF(width="1000", height="500", frameRate="60", backgroundColor="#000000")]
public class WindowTest extends Sprite
{
private static const ASPECT_RATIO:Number = 2.0;
public function WindowTest()
{
init();
}
private function init():void
{
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.nativeWindow.addEventListener(NativeWindowBoundsEvent.RESIZE, windowResizeEventHandler);
}
private function windowResizeEventHandler(evt:NativeWindowBoundsEvent):void
{
evt.currentTarget.width = stage.stageHeight * ASPECT_RATIO;
}
}
}
source
share