如何将 NativeApplication 实例传输到另一个 NativeWindow

发布于 2024-09-19 22:14:53 字数 1495 浏览 4 评论 0原文

不确定我的标题是否准确描述了我想要做的事情,但基本上我已经创建了一个新的 NativeWindow,如下所示(使用 Adob​​e NativeWindow 文档 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();

但是,现在我有了新窗口,我想关闭旧窗口并使新窗口成为活动的 NativeApplication,基本上将所有控制权转移到新窗口。知道如何做到这一点吗?非常感谢所有帮助。

编辑:

对于任何感兴趣的人,并且感谢所提供的答案,这就是我现在所做的。只需使用 Call this MyWindow.mxml 或其他内容创建一个 mxml 文件

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

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

,然后在主控制器中使用创建一个实例即可,

private var myWindow:MyWindow = new MyWindow. 

然后可以相应地设置高度宽度最小化和最大化属性,例如 myWindow.width = 400。然后你可以执行 window.open(true) 或 window.visible = false; window.open(true) - 后者使窗口不可见但可供使用。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

﹉夏雨初晴づ 2024-09-26 22:14:54

Jeff 在他的评论中几乎得到了答案,但他比我有更多的业力,所以我将评论作为答案;)

如果您查看 AIR -app.xml 文件,它包含应用程序最初是否可见的元素等等。

您要做的就是使其最初不可见。事实上,您根本不希望它有任何明显的存在。不过,它会按照您想要的方式生成一个本机窗口,如果您需要更改属性,请将其拆除并用新窗口替换。

表面上看起来很简单,但我确信还会有一些额外的复杂性。每个 NativeWindow 都有自己的阶段 (IIRC),因此您可能无法正确移动 ResourceManager。我从来没有做过比快速演示更进一步的事情,因此您可能会遇到无法克服的限制(正如杰夫的直觉告诉他的那样)

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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文