I'm trying to make a popup window class which will get a content DisaplyObject, and popup and display it in itself, but I'm cracking my head with matching the size of the content to the window or vise versa... I think that maybe the window is not display all of the stage or something ?!
The content get way too big..and goes out of bounds.
here is the code :
public class SubWindow extends NativeWindow{
public function SubWindow()
{
var windowOptions:NativeWindowInitOptions = new NativeWindowInitOptions();
windowOptions.systemChrome = NativeWindowSystemChrome.STANDARD;
windowOptions.type = NativeWindowType.UTILITY;
windowOptions.resizable = false;
super(windowOptions);
this.stage.align = StageAlign.TOP_LEFT;
width = 400;
height = 400;
title = "Are you sure?";
alwaysInFront = true;
activate();
visible = false;
addEventListener(Event.CLOSING, closeWindow, false, 0, true);
}
public function closeWindow(e:Event)
{
e.stopImmediatePropagation();
e.stopPropagation();
e.preventDefault();
visible = false;
}
public function setContent(cont:DisplayObject)
{
visible = true;
//this.width = stage.stageWidth;
//this.height = stage.stageHeight;
trace(cont.getBounds(stage), width, height, stage.stageWidth,stage.stageHeight);
cont.height = stage.stageHeight;
cont.width = stage.stageWidth;
cont.x = cont.y = 0;
this.stage.addChild(cont);
trace(cont.width, width, height, stage.stageWidth,stage.stageHeight);
}
}
Thanks, Mik
Now I've solved it i think!
First create your content:
Then create your window and set size and position
And set scale mode to no scale:
And then add the content
I still have some minor ssues when running on osX, but I think is has to do with the size of the system chrome.