First haXe Project
This is the result of transcribing an ActionScript 3 demo into haXe. It was fairly straightforward and the actual haXe compiler is very good. There was some weirdness with trying to use the Vector3D type but other than that everything was cut and dry. The original ActionScript 3 source is here and the haXe version here.
haXe First Impressions
First of all, I had already heard of motion-twin back when I was looking for OCaml Win32 bindings. After a couple of years I ran into my-mini-city and had come to find out that it was created with tools written by the same OCaml hacker. I had always wanted to mess with Flash (in a programmatic way) so I figured I'd give haXe a whirl. What I have come to find out is that the language itself is a comfortable mix of JavaScript, Java, and, if you look hard enough, OCaml. Anyone with C#, JavaScript, Java experience should feel at home with the syntax.
For example, even the code entry should make you feel at home:
class Main {
static function main() {
var application = new SpinningCube();
}
}
It's the good old public-static-void-main convention.
Class definitions are equally recognizable:
class Vec {
public var x : Float;
public var y : Float;
public var z : Float;
public function new(x:Float, y:Float, z:Float) {
this.x = x;
this.y = y;
this.z = z;
}
}
There is something you have to get used to if you are a hardcore JavaScript person tho'. The language does enforce compile time typing so you are going to have to get used to the typed variable declartions.
var myVar:SomeType;
As far as I can tell variable scope resolution works more like C++ in that you can shortcut the this qualification for member variables.
class Foo {
var x:Int
public function new(i:Int) {
x = i // <-- this is kosher
}
}
The biggest problem isn't going to be the language itself—even when I have those problems the compiler has been good at telling exactly what they are—but the API for Flash and Flash 9. I have no clue what the runtime conventions are and the haXe API documentation isn't very helpful with some of the interface points. Sure you can—and should—reference the Adobe Live Docs for ActionScript 3 but flash.Lib is somewhat of a mystery still and not documented beyond the types and function signatures.
