Flash/Actionscript 3:Flash 何时停止渲染以及如何保持活动状态?

发布于 2024-08-16 23:42:57 字数 342 浏览 3 评论 0原文

我有一个 flash/Actionscript 3 应用程序 (swf)。该应用程序每 2 秒向服务器发送一条消息。但是,在某些浏览器/操作系统中(例如 mac 中的 safari),浏览器失去焦点的那一刻,它会停止发送这些消息。

我在 EVENT.ENTER_FRAME 循环中发送这些消息,因此每次呈现应用程序时我都有机会发送消息。我的理论是,某些浏览器由于某种原因明显停止调用此方法/停止渲染,因为它失去了焦点。但是,我想继续发送这些消息。

我已经尝试使用计时器,这是一个每 2 秒调用一次的事件,但我在某处读到(并且我的测试似乎同意)该计时器也连接到渲染/帧输入,因此定时函数也不会被处决。

有办法做我想做的事吗?

I have a flash/Actionscript 3 application (swf). This application sends a message to a server every 2 seconds. However, in some browsers/operating systems (for example, safari in mac), the moment the browser loses focus, it stops sending these messages.

I send these messages in a EVENT.ENTER_FRAME loop, so every time the application is rendered I have the chance to send a message. My theory is that some browsers apperantly stop callling this method/stop rendering for some reason, because it has lost focus. However, I want to keep sending these messages.

I already tried to use a Timer, an event that would be called every 2 seconds, but I read somewhere (and my tests seem to agree) that this timer is also connected to the rendering/frame entering, so that timed function will also not be executed.

Is there a way to do what I want?

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

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

发布评论

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

评论(1

一直在等你来 2024-08-23 23:42:57

您可以使用MOUSE_LEAVE 舞台事件 检查您的 SWF 何时失去焦点。

我建议使用 ExternalInterface 建立swf 和 javascript 之间的连接。连接完成后,让 javascript 调用您的服务器而不是 flash,这可能会失去焦点。

出于好奇,为什么您需要每 2 秒轮询一次服务器?

You can use the MOUSE_LEAVE stage event to check when your swf has lost focus.

What I would recommend is using the ExternalInterface to establish a connection between the swf and javascript. As soon as the connection is done, have javascript call your server instead of flash, that may loose focus.

Out of curiosity, why would you need to poll the server every 2 seconds ?

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