views:

2223

answers:

4

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?

+7  A: 

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!

Branden Hall
Thanks for the info. I am definitely interested in designing my game with generics in mind. Though the current lack of support for reading SWCs is disappointing, i am sure i can work around it. Perhaps there are native haXe libraries that provide the same functionality of some of the adobe as3 core libs i've been using.
Jason Miesionczek
for 1) you could use also as3 written swcs in haxe. there is a compiler flag to use them as external libraries.
Hippo
A swc is just a zipped up SWF with other data. It is quite possible to use swfs with Haxe. There is an example here: http://haxe.org/doc/flash/aswingas3?lang=en and here: http://haxe.org/doc/flash/flex?lang=en
tylermac
+4  A: 

you can find a lot of helpfull stuff on haxelib.org ... (checkout haxelib for that matter (a bit like ruby gems, one could say)) ... there's also a 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 ... ;)

back2dos
wow, thanks for the info on haxe remoting. i also found out about SPOD, which looks like a really nice ORM to use in conjunction with neko server. I think i just solidified my technology choices :)
Jason Miesionczek
+1  A: 

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

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

Nosredna
A: 

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) Brandon 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.

Robert Sköld