Actionscript 3 与 Haxe:为新的 Flash 项目选择哪个?

发布于 2024-07-26 00:35:38 字数 295 浏览 14 评论 0原文

我正处于新 Flash 游戏项目的规划阶段,想知道使用哪种语言更好? 我已经对 Actionscript 3 有深入的了解,并且还没有使用过 Haxe,但我已经阅读了语言参考文档,看来 Haxe 具有我最喜欢的其他语言(C# 和 Ruby)的一些功能。

所以我的问题有两个部分:

1)Haxe 可以与闪存组件(swc 文件)互操作吗? 例如,如果我使用 Flash IDE 来设置某些控件的外观,我可以导入这些控件并在 Haxe 中使用它们吗?

2) Haxe 编译器有任何性能优势吗? 或者有什么陷阱吗?

I am in the planning stages of a new Flash game project and was wondering which language would be better to use? I already have a strong understanding of Actionscript 3, and have not worked with Haxe yet, but I have read the language reference docs and it seems that Haxe has some of the features from my other favorite languages, C# and Ruby.

So my question has two parts:

1) Can Haxe interop with flash components (swc files)? Like for instance if i use the Flash IDE to skin some controls, can i import those controls and use them in Haxe?

2) Are there any performance benefits to the Haxe compiler? or any gotchas?

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

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

发布评论

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

评论(5

全部不再 2024-08-02 00:35:38

1)是,也不是。 从 2.03 Haxe 开始可以导出 SWC。 这意味着您可以在 Haxe 中编写代码,编译为 SWC,然后将该 SWC 与 Flash 结合使用。 目前 Haxe 不支持 SWC 输入,仅支持输出(尽管我相信他们正在努力解决这个问题)。

2) 是的,使用 Haxe 有好处 - 与 Adob​​e 的编译器不同,Haxe 实际上在编译过程中做了一些优化(这一段时间以来一直是社区争论的焦点)。 此外,Haxe 使用了一些随 Flash Player 10 一起出现的“隐藏”新字节码,目前 Flash 或 Flex 都没有使用这些字节码 - 只有 Adob​​e 的 Alchemy(从 C/C++ 源代码交叉编译到 SWC)。

据我所知,唯一的“陷阱”是它有点奇怪的 ActionScript - 事情的不同之处足以让你陷入困境。 话虽如此,使用泛型和更快的代码等功能,付出的代价很小!

1) Yes, and no. As of 2.03 Haxe can export SWCs. This means you can write your code in Haxe , compile to a SWC and then utilize that SWC with Flash. Right now Haxe does not support SWC input, only output (though I believe they are working on this).

2) Yes, there are benefits to using Haxe - unlike Adobe's compilers Haxe actually does some optimizations during compilation (this has been a major bone of contention in the community for a while). In addition, Haxe utilizes some "hidden" new bytecodes that came into being with Flash Player 10 that currently neither Flash or Flex utilize - only Adobe's Alchemy (which cross-compiles from C/C++ source into SWCs).

The only "gotcha" that I know of is that it's kind of bizzaro ActionScript - things are just enough different that it will trip you up a fair amount. That being said, with features like generics and faster code that's small price to pay!

我三岁 2024-08-02 00:35:38

您可以在 lib.haxe.org 上找到很多有用的东西...(请查看 haxelib (有点像 ruby​​ gems,有人会说))...还有一个 AS3 到 Haxe 转换器...所以可以尝试将 corelib 的相关部分翻译为 Haxe ...不过,我想,需要一些手动修复。 ..
当谈到控件时,只需查看 Haxe gui 库...网络上有几个这样的库...

现在 Haxe 优点:
Haxe 的一个好处是,编译器速度更快,因此您不必花费大量时间进行编译...说实话,这会有所不同...

此外,Haxe 是一种更丰富的语言,正如 Branden 已经隐含的那样声明...我只是想补充一点,你真的应该检查一下枚举...

不过,Haxe 最好的一点是,当我编写服务器时,你可以使用相同的语言,再加上 Haxe remoting make 之类的东西你的生活超级轻松...

有一些 AS3 专家,但问题是,他们中的大多数都与这样一个事实有关:如果你尝试像在 AS3 中那样在 Haxe 中解决问题,该语言看起来很古怪,并且表明运行时的意外行为......如果你保持严格和打字,一切都会变得完美......

希望有所帮助......;)

greetz

back2dos

You can find a lot of helpful stuff on lib.haxe.org ... (checkout haxelib for that matter (a bit like ruby gems, one could say)) ... there's also an AS3 to Haxe converter ... so could try translating relevant parts of the corelib to Haxe ... some manual fixing will be required though, i guess ...
when it comes to controls, just check out the Haxe gui libraries ... there's a couple of them floating around the web ...

Now Haxe pros:
a good thing about Haxe is, that the compiler is much faster, so you don't spend a lot of time compiling ... seriously, it makes a difference ...

Also, Haxe is a much richer language, as branden already implicitely stated ... I just wanna add, you should really check out enums ...

Still, the best thing about Haxe is, that when i comes to write a server, you can stay with the same language, plus things like Haxe remoting make your life super easy ...

There are some AS3 pros, but the thing is, that most of them are just related to the fact, that if you try solving problems in Haxe the way you would in AS3, the language seems quirky and shows unexpected behaviour at runtime ... if you stay strict and typed, everything turns out perfect ...

Hope that helps ... ;)

greetz

back2dos

对你而言 2024-08-02 00:35:38

今天发布新版 Haxe。 添加 C++ 的官方目标。

因此,现在您可以使用相同的源来定位 ActionScript 和 C++。

New release of Haxe today. Adds official target of C++.

So now you can target ActionScript and C++ with the same source.

感情洁癖 2024-08-02 00:35:38

NME 改进了 Haxe 的跨平台支持,为 Windows、Mac、Linux、Android、iOS、webOS、Flash 和 HTML5 应用程序提供单一 API,无需大惊小怪。

Haxe 编译器明显比 MXMLC 快,特别是如果您习惯从 Flash IDE 进行编译,而不是从托管 Flex 编译器 shell 的 IDE(如 FlashDevelop)进行编译。 如前所述,还有许多添加的语言功能,例如迭代器、typedef、结构、宏和其他必备功能。

最棒的是,由于您始终可以瞄准 Flash,因此几乎没有风险。 Haxe 语言非常相似,如果您不介意支持单一平台,则可以针对 Flash 支持的所有功能。 然而,只要您坚持使用 NME 的跨平台 API,您就可以体验移动和桌面平台的巨大性能和功能优势,或者尝试 HTML5 支持。

最后,还有一个 SWF 库,可以从 C++ 访问 SWF 内容。 当然,这在 Flash 目标上一直是可能的,但很快就能够在 Flash IDE 中定义接口,并在移动或桌面 C++ 应用程序以及 Flash/AIR 目标中使用它。

NME improves on Haxe's cross-platform support to provide a single API for Windows, Mac, Linux, Android, iOS, webOS, Flash and HTML5 applications without fuss.

The Haxe compiler is notably faster than MXMLC, especially if you are used to compiling from the Flash IDE, instead of an IDE that hosts the Flex compiler shell, like FlashDevelop. As mentioned, there are also a number of added language features, like iterators, typedefs, structs, macros and other nice-to-haves.

The great thing is that since you can always target Flash, there's little risk. The Haxe language is very similar, and if you don't mind supporting a single platform, you can target all of Flash's supported features. However, to the degree that you stick with NME's cross-platform API, you can experience huge performance and feature benefits for mobile and desktop platforms, or experiment with HTML5 support.

Lastly, there's a SWF library that makes it possible to access SWF content from C++. This has always been possible on the Flash target, of course, but soon it should be reasonable to be able to define an interface in the Flash IDE, and use this in mobile or desktop C++ applications as well as the Flash/AIR target.

宁愿没拥抱 2024-08-02 00:35:38

1) 您可以在使用 -swf-lib 编译器参数进行编译时包含一个 swf 库(而不是 SWC),如果您需要多个库,您可以使用 swfmill< 合并多个库/代码> 工具。 Haxe 文档 中有一个示例。

2)布兰登完美地回答了这个问题:)尽管我可能会补充一点,确实可以提高性能的一项功能(尤其是在闪存应用程序中)是“内联”。 由于 Nicolas(Haxe 的创建者)添加了更多字节代码对内联函数的优化。 还有更多计划中的优化

1) You can include one swf library (instead of a swc) while compiling using the -swf-lib compiler argument and if you need more than one lib you can merge multiple using the swfmill tool. There's an example of this in the Haxe docs.

2) Branden answered this one perfectly :) Although I might add that one feature that does improve performance, in flash applications especially, is "inlining". Since Nicolas (the creator of Haxe) added even more byte code optimizations on inlined functions. And there's also even more of those optimizations planned.

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