将 Actionscript 转换为 Javascript

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18245572/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 11:11:32  来源:igfitidea点击:

Convert Actionscript to Javascript

javascriptactionscriptcomparisonflashconverter

提问by ic2000

I was just wondering is there anyway to convert Actionscript to Javascript. When I say Actionscript I mean Actionscript 3. I've used google swiffy but Actionscript 3 is hardly supported. I've also heard of Jangaroo but its not what I want. Even if its a code comparison! Thanks!

我只是想知道是否有将 Actionscript 转换为 Javascript 的方法。当我说 Actionscript 时,我的意思是 Actionscript 3。我使用过 google swiffy,但几乎不支持 Actionscript 3。我也听说过 Jangaroo 但它不是我想要的。即使是代码比较!谢谢!

回答by Bryce

Javascript and ActionScript (especially AS3) are syntactically similar languages and both are based on the ECMAScript Specification. There are some small differences in the actual code such as:

Javascript 和 ActionScript(尤其是 AS3)在语法上是相似的语言,并且都基于 ECMAScript 规范。实际代码中存在一些小的差异,例如:

//Actionscript:
var a:String = new PlayerName();

//JavaScript:
var a = new PlayerName();

This is a demonstration that JavaScript does not have explicit variable type declarations, but this is not the real problem.

这证明了 JavaScript 没有显式的变量类型声明,但这并不是真正的问题。

What you're asking goes much further than syntactic incompatibilities, as JS and AS work with completely different APIs. ActionScript has stages, frames and other Flash-basedthings which do not exist in JavaScript's environment. JavaScript - usually running in a browser - is used to manipulate documents, DOM nodes and CSS properties.

您要问的不仅仅是语法不兼容,因为 JS 和 AS 使用完全不同的 API。ActionScript 具有JavaScript 环境中不存在的阶段、框架和其他基于 Flash 的东西。JavaScript - 通常在浏览器中运行 - 用于操作文档、DOM 节点和 CSS 属性。

This means that unless you're just doing simple function calls and mathematics (without any dependency on the user or their environment) the things your program is doing simply cannot be transferred to another environment. For example, you cannot tell JavaScript to play()or goToAndStop()because there are no frames to play, stop or go to in a HTML document.

这意味着除非您只是进行简单的函数调用和数学运算(不依赖于用户或其环境),否则您的程序所做的事情根本无法转移到另一个环境中。例如,您不能告诉 JavaScriptplay()goToAndStop()因为在 HTML 文档中没有要播放、停止或转到的帧。

Unfortunately, I think what you're wondering is valid, but the question is almost certainly incorrect. If you have an application created in Flash or any other AS-enabled environment, you probably want to think about portingor re-writingit to the new context.

不幸的是,我认为您想知道的是有效的,但这个问题几乎肯定是不正确的。如果您有在 Flash 或任何其他启用 AS 的环境中创建的应用程序,您可能需要考虑将其移植重新编写到新的上下文中。

回答by Christophe Herreman

You might have a look at Falcon JS: https://github.com/apache/flex-falcon

你可以看看 Falcon JS:https: //github.com/apache/flex-falcon

回答by priyanka

http://www.gotoandlearn.com/play.php?id=172Just check it out the above. It might be useful.

http://www.gotoandlearn.com/play.php?id=172看看上面的。它可能有用。