Reputation: 2392
AIR's spark.components.WindowedApplication
would resize its contents automatically as I manually stretch window bounds or maximize/restore it. But spark.components.Window
class does not provide such functionality 'out of the box': the contents of the Window don't change their size as I stretch/maximize/restore the window, when the corresponding spark.components.Window.nativeWindow
instance does resize its bounds. My AIR application is required to open multiple windows, and resizable ones. How can I make them automatically resize their contents to match the nativeWindow bounds?
Upvotes: 0
Views: 1218
Reputation: 2392
The solution is to listen to a RESIZE event coming from the NativeWindow and then to manually set stageWidth
and stageHeight
on Window's stage
instance. See code below.
override public function open(openWindowActive:Boolean=true):void {
super.open(openWindowActive);
if (nativeWindow) {
chromeWidth = nativeWindow.width - this.width;
chromeHeight = nativeWindow.height - this.height;
nativeWindow.addEventListener(NativeWindowBoundsEvent.RESIZE, onNativeResize);
}
}
private function onNativeResize(event:NativeWindowBoundsEvent):void {
stage.stageWidth = event.afterBounds.width - chromeWidth;
stage.stageHeight = event.afterBounds.height - chromeHeight;
}
Upvotes: 0
Reputation: 949
Assuming you mean the spark.components.Window
, this is based on the skinnablecontainer so there shouldn't be anything preventing you from using a percentbased layout / constraint.
<s:Window xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="100%" height="100%">
Other methods for manually handling this sort of thing include listening for the ResizeEvent coming from the stage.
Upvotes: 1