0
votes

Not sure if my title accurately describes what I'm trying to do, but basically I've created a new NativeWindow as follows (using an example from the Adobe NativeWindow documentation http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/NativeWindow.html?filter_flex=4.1&filter_flashplayer=10.1&filter_air=2#minSize):

var windowOptions:NativeWindowInitOptions = new NativeWindowInitOptions();
windowOptions.systemChrome = NativeWindowSystemChrome.STANDARD;
windowOptions.type = NativeWindowType.NORMAL;

var newWindow:NativeWindow = new NativeWindow(windowOptions);
newWindow.stage.scaleMode = StageScaleMode.NO_SCALE;
newWindow.stage.align = StageAlign.TOP_LEFT;
newWindow.bounds = new Rectangle(100, 100, 800, 800);

newWindow.activate();

However, now that I have my new window, I want to close the old window and make the new window the active NativeApplication, basically transferring all control over to the new one. Any idea how to do this? All help greatly appreciated.

Edit:

For anyone who is interested, and thanks to the answers provided, here's what I now do. Just create an mxml file using

<?xml version="1.0" encoding="utf-8"?>

<mx:Window
xmlns:mx="http://www.adobe.com/2006/mxml"
...
>

Call this MyWindow.mxml or whatever, and then in the main controller create an instance of this using

private var myWindow:MyWindow = new MyWindow. 

You can then set the height width minimizable and maximisable attributes accordingly, like myWindow.width = 400. To open the window you can then do either window.open(true) or window.visible = false; window.open(true) - the latter making the window invisible but available for use.

1
My intuition is that this can't be done, but I'm unclear if that intuition is incredibly flawed or not. Closing the original window is like closing the app, right? Perhaps not. Have you tried just making the original window invisible [like a hidden controller] that just spawns multiple NativeWindows as needed?JeffryHouser
I'm using Window instead of creating a NativeWindow and binding stuff to it. Not sure which is the best implementation but my way works for me.Craig Myles

1 Answers

0
votes

Jeff's pretty much got the answer in his comment, but he's got way more karma than me so I'll comment as an answer ;)

If you look at your AIR -app.xml file, it has elements for whether the application is initially visible, etc.

What you want to do, is make it initially invisible. In fact you don't really want it to have any visible presence at all. What it will do though is spawn a Native Window the way you want it, and if you need to change the properties, tear that one down and replace it with a new one.

I looks pretty simple on the face of it, but I'm positive there will be some additional complications. Each NativeWindow has its own stage (IIRC) so you might not have the resourceManager moved across correctly for example. I've never gone further than a quick demo with this, so you might run into a limitation that's insurmountable (as Jeff's intuition is telling him)