OK I created a class called WindowManager, so far it just as 1 method, to create a new window. You pass the DisplayObject to it that should be contained in the window. The problem is if I added a newly created display object to the new window it does not show up. However if I first as the new display object to the main window, then try to add it to the new window it works right.
here is this class:
package
{
import flash.display.DisplayObject;
import flash.display.NativeWindow;
import flash.display.NativeWindowInitOptions;
import flash.display.NativeWindowSystemChrome;
import flash.display.NativeWindowType;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.geom.Rectangle;
import flash.display.Screen;
public class WindowManager
{
public function WindowManager()
{
}
public function newWindow(content:DisplayObject):void
{
var windowOptions:NativeWindowInitOptions = new NativeWindowInitOptions();
windowOptions.systemChrome = NativeWindowSystemChrome.NONE;
windowOptions.type = NativeWindowType.NORMAL;
windowOptions.transparent = true;
var newWindow:NativeWindow = new NativeWindow(windowOptions);
newWindow.stage.scaleMode = StageScaleMode.NO_SCALE;
newWindow.stage.align = StageAlign.TOP_LEFT;
newWindow.bounds = new Rectangle(0, 0, content.width, content.height);
newWindow.title = "New Window Number 2";
newWindow.alwaysInFront = true;
newWindow.x = (Screen.mainScreen.bounds.width - newWindow.bounds.width)/2;
newWindow.y = (Screen.mainScreen.bounds.height - newWindow.bounds.height)/2;
newWindow.stage.addChild(content);
newWindow.activate();
}
}
}
If I call it like this:
var notifierBox:NotifierBox = new NotifierBox();
new WindowManager().newWindow(notifierBox);
The new window will contain nothing..but If I add the dispay object to the main window before trying to add it to the new window it works fine:
var notifierBox:NotifierBox = new NotifierBox();
addChild(notifierBox);
new WindowManager().newWindow(notifierBox);
Can someone tell me why?
Thanks.