简体   繁体   English

如何为基于Flex AIR的应用程序提供多进程体系结构?

[英]How to have a multi process architecture for my Flex AIR based application?

I developing an AIR application in Flex that would be dealing with playing different SWFs. 我在Flex中开发了一个AIR应用程序,该应用程序将处理播放不同的SWF文件。 I am finding some issues as these SWFs that I am playing are heavy. 我正在发现一些问题,因为我正在玩的这些SWF太重了。 I find that the animation is not smooth and is causing the graph of CPU usage to go high (my be because single thread architecture of Flex). 我发现动画不流畅,导致CPU使用率上升(我是因为Flex的单线程体系结构)。 I am therefore planning to have a multi process architecture for my application. 因此,我计划为我的应用程序提供一个多进程体系结构。 Something like Google Chrome. 像谷歌浏览器。 I have one main application as one process and other SWFs would be playing in separate process but should be seen inside the main application window. 我有一个主应用程序作为一个进程,而其他SWF将在单独的进程中运行,但应在主应用程序窗口内看到。 How to make it possible in Flex? 如何在Flex中实现? Thanks!! 谢谢!!

Unfortunately the flash runtime is single threaded. 不幸的是,Flash运行时是单线程的。 However, you can simulate threads by a judicious use of events. 但是,您可以通过明智地使用事件来模拟线程。 You can gain a perceived performance increase by letting the flash player handle when to execute your code by breaking up large blocks of code into smaller bite-sized methods that get called by events. 通过让Flash Player处理何时执行代码,可以将大型代码块分解为较小的,可被事件调用的方法,从而获得可观的性能提升。

I highly recommend reading up on the elastic racetrack: http://drawlogic.com/2008/04/22/a-peek-into-the-as3-and-avm2-virtual-machine-and-elastic-racetrack/ 我强烈建议您阅读弹性赛道: http : //drawlogic.com/2008/04/22/a-peek-into-the-as3-and-avm2-virtual-machine-and-elastic-racetrack/

Another alternative would be to distribute your logic into multiple SWF files and have them communicate via LocalConnection. 另一种选择是将您的逻辑分发到多个SWF文件中,并通过LocalConnection进行通信。 If I'm not mistaken, in Chrome each flash player instance is supposed to get its own process; 如果我没记错的话,那么在Chrome中,每个Flash Player实例都应该有自己的进程; you should be able to consume plenty of CPU that way. 您应该能够以这种方式消耗大量CPU。

You aren't going to have any luck trying this with AIR. 使用AIR进行尝试不会有任何运气。 Perhaps with the Flash Player, as you could use the HTML page as a surrounding container, but you have no options with AIR for this. 也许可以使用Flash Player,因为您可以将HTML页面用作周围的容器,但是AIR对此没有任何选择。

It has to be said, if you are suffering such performance issues, there are almost certainly things you can do better in improving the performance. 必须说,如果您遇到这样的性能问题,几乎可以肯定,您可以在改善性能方面做得更好。

Rather than fixing the symptoms ( App runs slowly ), how about tackling the cause ( The code causing the app to run slowly )? 除了解决症状(App运行缓慢)之外,如何解决原因(导致App运行缓慢的代码)呢?

This is not possible because the flash player does not allow multiple threads. 这是不可能的,因为Flash Player不允许多个线程。 Hopefully they will change this in the future. 希望他们将来会改变这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM