在Linux服务器上执行Actionscript
我有一组大约 5 个 ActionScript 3 类,当前在 Flex 4 应用程序中使用。虽然它们的输出用于在我的 Flex 应用程序中显示图形等,但这些类本身没有可视组件 - 它们仅用于执行复杂的数学计算(我最初在 AS3 中实现它们,以避免在需要计算时不断调用服务器)弹性应用程序)。
然而,我现在希望在我的 Linux 服务器上使用相同的数学计算引擎,以便可以在 PHP 中完成计算。有没有办法访问服务器上这些类中的逻辑?我真的很想避免在 PHP 中重新实现复杂的逻辑。
非常感谢您提供的任何帮助!
I have a set of ~5 ActionScript 3 classes that are currently used within a flex 4 application. Although their output is used to display graphs etc in my flex app, the classes themselves have no visual components - they are only used to do complex math computations (I originally implemented them in AS3 in order to avoid constant server calls when computations were needed by the flex app).
However, I now want to make the same mathematical computation engine available on my linux server so the computations can be done within PHP. Is there any way at all to access the logic in these classes on the server? I would really like to avoid re-implementing the complex logic in PHP.
Thanks so much for any help you can give!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的 AS3 类中有多少行代码,以及您需要处理什么样的负载?
如果您正在构建的东西不只是一次性使用,那么最简单的方法可能是将 ActionScript 移植到 JavaScript。据我所知,没有任何自动转换器,但 JavaScript 和 AS3 非常相似,除非您的五个类有数千行代码,否则您应该能够快速完成它。一旦将其移植到 JavaScript,就可以轻松地在 Node.js 中运行,直接通过您选择的 VM,甚至在用户的浏览器中运行。
如果你只需要这个来抓痒或者有限的使用,你可以直接在 狨猴或redtamarin。但据我所知,这些目前都不适合生产使用。
然而,如果您在高可用性、高流量的 PHP 应用程序中使用它,我认为从长远来看,只需将代码移植到 PHP,您就会体验到更少的痛苦。 AS3 和 PHP 在语法上非常相似,您可能可以直接进行移植。
最后,您可以在此线程中找到一些进一步的讨论和链接:是否可以创建“命令行”swf?
How many lines of code in your AS3 classes, and what kind of load do you need to handle?
If you're building anything for more than one-off use then the easiest route is probably porting your ActionScript to JavaScript. There aren't any automated converters that I know of but JavaScript and AS3 are so similar that unless your five classes have thousands of lines of code you should be able to make short work of it. Once you've ported it to JavaScript it'll be trivial to run in Node.js, directly through the VM of your choice, or even in the user's browser.
If you only need this to scratch and itch or for limited use you may be able to get away with running AS3 directly in Tamarin or redtamarin. However as far as I know neither of these are currently suitable for production use.
If you are using this in a high-availability, high traffic PHP app, however, I think you'll experience a lot less pain in the long run just porting your code to PHP. AS3 and PHP are similar enough in syntax that you could probably just do a straight port.
Finally, you can find some further discussion and links in this thread: Is it possible to create a 'command line' swf?
您可以使用 redtamarin
http://code.google.com/p/redtamarin/
从 Linux 服务器的角度来看,您将能够运行
您的 AS3 源代码作为 CGI(直接 AS3 脚本或编译为 ABC),
或者您也可以将您的 AS3 代码捆绑到一个 exe 中,然后您将通过 PHP 调用该文件
,或者使用 binfmt_misc
http://code.google.com/p/redtamarin/wiki/RunningShellScripts#Registering_an_extension_as_non-native_binaries_(Linux_only)
在生产和开发服务器上,我们使用 redtamarin
中 。文档你会看到你有很多选择
重用 AS3 代码:stdin/stdout/stderr、套接字、管道、CGI 等。
You can use redtamarin
http://code.google.com/p/redtamarin/
from a Linux server standpoint you will be able to run
your AS3 source code as CGI (either the AS3 script directly or compiled as ABC)
or you can also bundle your AS3 code into an exe that you will then call via PHP
or make your AS3 script as executable with binfmt_misc
http://code.google.com/p/redtamarin/wiki/RunningShellScripts#Registering_an_extension_as_non-native_binaries_(Linux_only)
here on production and development servers we use redtamarin
look a bit in the documentation you will see you have a lot of options
to reuse your AS3 code: stdin/stdout/stderr, sockets, pipes, CGI, etc.