0

For an application I'm creating in Adobe Air, I'd like to close the default window immediately and open a new one, then use that new window as the 'main' one (but still be able to make references to the stage).

This code closes the current window and creates a new one. How do I replace the current window with the new one?

var throwWindow:NativeWindow = this.stage.nativeWindow;

var options:NativeWindowInitOptions = new NativeWindowInitOptions();
options.systemChrome = NativeWindowSystemChrome.STANDARD;
options.type = NativeWindowType.NORMAL;
options.transparent = false;
options.resizable = false;
options.maximizable = false;

var clientWindow:NativeWindow = new NativeWindow(options);
clientWindow.activate();

throwWindow.close();
Olin Kirkland
  • 548
  • 4
  • 23
  • 2
    Why do you want to do this? What exactly are you asking? You want the content from the first window in the second window? If so just add the document class to the second windows stage. `clientWindow.stage.addChild(this);` if the code you show is in your document class – BadFeelingAboutThis Dec 10 '15 at 21:53
  • I want to do it because I can't control the NativeWindow options of the default window using ActionScript, so I'm removing it and replacing it with a window I can change the options of. Thanks for your answer, it worked (yes, that code was in my document class). If you answer, I'll check it as answered. I had no idea you can add your document class that easily to a NativeWindow. Awesome! – Olin Kirkland Dec 10 '15 at 21:59

1 Answers1

1

I'll summarize your question in that you would like to move your document class from one window to another.

You can actually re-parent your document class as easily as any other display object. So to movie it from one window to another you can do the following (where this is the reference to your document class)

clientWindow.stage.addChild(this);
BadFeelingAboutThis
  • 14,445
  • 2
  • 33
  • 40