Flex4 AIR NativeWindow 在启动时不会保持不可见状态

发布于 2024-10-20 10:32:00 字数 709 浏览 6 评论 0原文

在 Flex 3 中,我将 AIR 应用程序设置为始终使本机窗口在启动时不可见,以便应用程序可以从本地共享对象调用存储的窗口位置和大小。之后,它设置最后使用的窗口位置和大小,然后通过调用nativeWindow.activate()使本机窗口可见。

非常干净,始终工作完美!现在进入 Flex 4 ...

在 Flex 4 中,由于某种原因,AIR 描述符文件中的可见属性似乎被忽略。文档指出它应该可以工作,但在我的简单测试中,AIR 总是使窗口在启动后立即可见,无论我是否将visible 设置为 false。

有谁知道如何让它像在 Flex 3 中一样工作?

编辑:好吧,文档指出 Flex mx:WindowedApplication (和 s:WindowedApplication?!?) 组件会在调度 applicationComplete 事件之前立即自动显示并激活窗口,除非在 MXML 定义中将visible 属性设置为 false。

这解释了为什么它本身就可见,即使它在某种程度上违背了将可见设置为 false 的目的。 但是,如果将 WindowedApplication.visible 设置为 false,应用程序窗口很快就会按预期可见,但几分之一秒后立即再次变得不可见。似乎 nativeWindow.activate() 被调用得太早,因为如果我等待一帧然后调用它,它就会按预期工作并保持可见。但是我怀疑使用 callLater 或 EnterFrame 处理程序等待触发下一帧是否是最佳实践。

In Flex 3 I had my AIR application setup to always have the native window being invisible at startup so that the app can recall stored window position and size from a local shared object. After that it sets the last used window pos and size and THEN it makes the native window visible by calling nativeWindow.activate().

Very clean, always worked flawless! Now enter Flex 4 ...

In Flex 4 the visible property in the AIR descriptor file seems to be ignored for some reason. The documentation states that it should work but in my simple test AIR always makes the window visible instantly after launch, regardless if I have set visible to false.

Does anyone know how to get this working like it was in Flex 3?

EDIT: Ok so the docs state that the Flex mx:WindowedApplication (and s:WindowedApplication?!?) component automatically displays and activates the window immediately before the applicationComplete event is dispatched, unless the visible attribute is set to false in the MXML definition.

This explains why it goes visible all by itself even if it somehow defies the purpose of setting visible to false in the first place.
However if setting WindowedApplication.visible to false the app window shortly goes visible as intended but then instantly goes invisible again after a fraction of a second. It seems that nativeWindow.activate() is called too soon because if I wait for one frame and then call it, it works as it should and stays visible. However I doubt this is best practice to use callLater or an enterFrame handler to wait for the next frame to be triggered.

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

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

发布评论

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

评论(1

银河中√捞星星 2024-10-27 10:32:00

您是否尝试在应用程序初始化时将可见设置为 false?将其放在您的 WindowedApplication 标签上。

initialize="visible=false" creationComplete="visible=true"

Have you tried to put visible in false when the application is initalizing? Put this on your WindowedApplication Tag.

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