Before I start talking about my first “HTML5” experience, let me say something: after 15 years of c++ game development today I make games at the company where I work and I experiment at home using ActionScript 3, C# (Unity) and Haxe.

Do I miss the C++ times? Not really, actually what I love about the aforementioned languages is that they allow me to focus on code design instead of lower level problems and you know what? I turned out to be a code design freak.

In fact I love following the SOLID principles, recognize patterns in my code, develop frameworks, solve issues related to modularity, encapsulation, uncoupling, communication, dependency injection and such; all stuff that can be properly managed with concepts introduced with such high level languages.

With this preamble you could guess why I never wanted to mess up with javascript. I do not want to spend much words about the reasons why I do not like js; it is enough for me to know that it is quite similar to actionscript 2 and I used to work long enough with actionscript 2 to say, without fear to be much wrong, that javascript is surely a good option to write websites and simple games, but it is not good enough to develop and maintain complicated projects and guess who agrees with me? Sure Google does.

Google has some experience with javascript based projects and indeed they are trying to kill it in every way, at least in its current form. GWT, Dart and playN are proofs that I am not so far from the truth.

I also currently do not care much about learning how CSS 3 and the HTML DOM work. So consider this article a solution to be able to work in HTML5 without be forced to know the technology behind it.

All that said, when I heard for the first time that Haxe could export to HTML5, I was already quite excited. After other projects started to appear and among them the most interesting to me were the ones able to convert actionscript code to javascript.

While I have the intention to test them in the future, this article focuses only on the experiment I made with Haxe.

I like Haxe, I like it at lot. It is what ActionScript 4 is supposed to be for me. There are some glitches, sure, but they will be very likely addressed with the next major release. However what can be more lovely than an actionscript looking like language with generic support?! C#? Yeah, sure, but currently there are not free solutions to export to javascript (at least that I know of).

how Haxe code looks like:

import flash.display.Bitmap
import flash.display.BitmapData
import flash.geom.Point
import flash.geom.Rectangle
import mylittleframework.Vector2D;
class Explosion extends Bitmap
 var _stripe:BitmapData;
 var _worldPos:Vector2D;
 var _lastTime:Float;
 var _index:Int;

 public function new(worldPos:Vector2D) 
 super ();

 _stripe = nme.Assets.getBitmapData ("assets/images/explosion.png");
 bitmapData = new BitmapData(48, 48);
 bitmapData.copyPixels(_stripe, new Rectangle(0, 0, 48, 48), new Point(0, 0));

 _worldPos = worldPos;

 x = mod(_worldPos.x - (Camera.bound.x)) - 24;
 y = mod(_worldPos.y - (Camera.bound.y)) - 24;

 this.addEventListener(Event.ENTER_FRAME, onEnterFrame); //I was lazy and I did this ,but it should be avoided to improve the performance

 _lastTime = flash.Lib.getTimer();
 _index = 0;

However the real question could be: is Haxe good enough to be used for a professional project? Well this question is harder to answer and I searched for the answer developing a simple project.

Haxe is the fruit of Nicolas Cannasse’s mind, who must be a sort of genius. I say this because I do not see how otherwise he can successfully manage so many projects! Surely he is helped by another bunch of guys, but not many.

So can such a project have enough support to guarantee a smooth professional development? Well, one consequence of the fact that Nicolas cannot control time is that the documentation is not very detailed. Although it is good enough to understand most of the language paradigms, sometime it is frustrating to find information even if the Haxe group is full of users willing to help.

I must add that there are also several libraries developed by third party authors already available, but most of them are not really multiplatform, so they must be chosen carefully.

The nice thing is that the most supported and useful libraries can be easily installed using the command line Haxelib that makes everything very straightforward.

Enough talk, let’s get started:

First you need an IDE. Although a good number of IDEs support Haxe, my favourite currently is Flashdevelop, also because I do not know the other ones. Nevertheless it is a great IDE, light and fast. Grab it and install it and remember that it works only on windows. If you use linux or mac-os, a free alternative seems coming soon based on monodevelop.

Now it is the time to install Haxe and its libraries, however I suggest to use the NME installer in place of the Haxe one, I will