Documenting Haxe and Javascript

There used to be a website that got you started with Haxe and js (it was really old, when Haxe was spelled “haXe”).

But that website is no more. I already started with HaxeNode and it seems fitting to also document HaxeJS. So I decided to get some of that back. Based upon the information from the old site and my own need to document this.

How will this help me?

It will get you started with javascript and Haxe. How to setup your project, install externs and how to work with them. This probably will never be a complete documentation but it will help you get started!

Documentation goals

I wanted to make contributing to this documentation as easy as possible.
That’s why I use Markdown; developers use it, but is really just plain English so everybody can write documentation!
And this documentation hosted on Github, developers favorite place to store code.
Even if you are not a developer and/or don’t want to clone everything, you still can modify the files on the website (you need account to login in and change the .md files).


Go visit, and let me know what you think of it


Haxe Openfl

Scraping with Haxe

A quick post about something that grabbed my attention quickly.


Web scraping (web harvesting or web data extraction) is a computer software technique of extracting information from websites.


I already did some research on the subject when I was playing around with my raspberry pi. There is a lot out there, especially for python.

But what about my favourite programming language Haxe?

Again this is a quick search! And this is what I found.

A (very?) old project from Jonas Malaco Filho on github. Check out this code : jonas-haxe and specificly the scraper part of it. Written for Neko, with primarily undocumented classes like neko.vm.Mutex Once you have the html page you can start getting the data from it!

You will need a html/xml parser; I found one written by Yaroslav SivakovHtmlParser haxe library It also can be found on haxelib:

I found a little (old) project haxe/php project that I will post as a reference But then it stops…

Not a field that a lot of haxe-developers walk. Fun!

Update #2

  1. The htmlparser doesn’t work with the html code I am scraping. So I need to focus the parts I want to use. Regular expressions are the way to go, and I suck at them. Luckily I found a online tool that helps with testing the regex: from an old flash hero gskinner.
  2. Another thing I ran into, was the data from https sites. You need something “extra” to download html files from there: install hxssl via haxelib haxelib install hxssl and add it to your build.hxml -lib hxssl

Update #1

I am coding this with openfl/regular expressions, but perhaps a better way to-go is node.js! And you can use node.js with Haxe (perhaps not completely ready: hxnodejs but probably good enough for the examples below).

I can’t really say how to start with node.js and Haxe because I have never tried it, but what I have red about it shouldn’t be a big problem. Fun again!

Read this

Some interesting reads… somewhat related to haxe

Design Haxe Openfl Urban papercraft

Openfl papertoy art project

I love to create projects where you take stuff from the digital world (temporarily, intangible) and drag it into the “real” world. This project is a good example of that. I create a papertoy generated in code and cut by a machine.

Besides filling my blog with new content, I have two other reasons to write this post:

  1. You can use Haxe/Openfl for something else then game-developement! I know I am not the only one, but this group of developers are not as present as the game-defs.
  2. It’s a long and complicated process to get to the end result: it’s difficult to explain this in detail to others, so I wrote down the whole story for interested friend/family/colleagues/fans???

If I ever grow a pair, this post be one of the two talks I would give during wwx2015 just to balance the all tech talks during the event.
But nothing is growing besides my hair, so instead I will write about the process and end-result.

Feedback is always nice, so please don’t hesitate to comment!

Haxe Openfl

navigateToURL for Openfl

I have a Flash background.
And I notice that I first think (or Google) what would the code be in Flash and then try to convert it to Haxe/Openfl

Same with:
<a href="open-link-in-new-window" target="_blank">


var myURL:URLRequest = new URLRequest("open-link-in-new-window");
navigateToURL(myURL, "_blank");


var myURL:URLRequest = new URLRequest("open-link-in-new-window");
openfl.Lib.getURL(myURL, "_blank");

Haxe Openfl

Using svg for assets in Openfl

I wanted to use svg for icons in an Openfl project.
It’s not intuitive to do this, so I wrote it down for future use.

What are svg files?

Scalable Vector Graphics (SVG) is an XML-based vector image format for two-dimensional graphics with support for interactivity and animation.


Good to remember that they scale awesomely without lost of resolution!

How to add it to your project

You can find the svg code on github.
But you can install it easier with haxelib

Open your terminal and write:

haxelib install svg

To add it to an OpenFL project, add this to your project file:

<haxelib name="svg" />


import openfl.Assets;
import openfl.display.Shape;
import openfl.display.Sprite;
import format.SVG;
class SVGExample extends Sprite

  public function new()
    var svg : SVG = new SVG(Assets.getText("assets/openfl.svg"));
    var shape : Shape  = new Shape();

But now the cool part: it scales without losing resolution

Check the highlighted line for the changes,

import openfl.Assets;
import openfl.display.Shape;
import openfl.display.Sprite;
import format.SVG;
class SVGExample extends Sprite

  public function new()
    var svg : SVG = new SVG(Assets.getText("assets/openfl.svg"));
    var shape : Shape  = new Shape();

for the curious:


  • I remembered this gist, which explains almost everything.
  • Get icons here, they are free for download as long as you credit freepik
  • Featured image from webdesignerdepot
Haxe Openfl

Delay call, Timer delay in Haxe

When I started programming for as3, I started to collect little snippets of code. Some to explain the transition from as2 to as3. And some just to have one place to go to when I forgot how it worked… I decided to do it also for Haxe and Openfl. For some reason I forget some stuff easily. This is one I need often and forget easily:

How do you call a function with delay? (without a tweening engine!)

Not that difficult:

haxe.Timer.delay(someFunction, 1000);
But what if you want to send some extra parameters?

How do you call a function (with parameters) with delay?

(without a tweening engine!) I found my answer on stack.

update1 : this only works with flash, java, js, python

haxe.Timer.delay(callback(someFunction,"abc"), 10);

But I prefer a more readable version (probably because it looks very much like the javascript version), also mentioned in the same post.
haxe.Timer.delay(function () { func(arg1, arg2); }, delay);

update 2: needed it for a quick prototype in Haxe / Neko

// do something delayed


Haxe Open source / Freeware

Pixel Sprite Generator Editor

Recently I ran into this awesome project by Dave Bollinger: Pixel Spaceship (this project is currently not live anymore but still can be viewed via

And I had to build something with it. And build it in 8 hours.

I knew that wouldn’t be to difficult because I found Dave’s project via a haxe port of a javascript port of the original work of Dave.

My plan is to create a random papertoy based upon the principle Dave explains on his website.
And the first thing I needed was something to test my idea in editor so it would be easier to see the result.

And there it is:


check the code on github.

Of course it wasn’t exactly 8 hours, and it’s not finished but it works for the purpose I was building it for.
There are probably a lot of issues with it and currently it only exports to Neko.

But it could be a start of an sprite editor for example 🙂 .

Libs used

* Openfl:
* Haxe procedural sprite generator:
* Haxe port of Keith Peters minimalcomps:

Animation Haxe Open source / Freeware

Tween engine Go – part 2

My last post was about my new WIP tween library Go.

I have been updating my little experiment and it’s getting better.
Looking into other libraries codes is very educational.

Does it perform as good as the default Haxe tween engine Actuate?
Yeah that would have been great, but nope… around 1300 object, Go will start dropping frame-rate in Flash.

My goal was to create a lightweight, simple, compact, chainable tween library for haxe/openfl.

Could I perform as good as Actuate?
I am not sure, Actuate is very well written and Joshua Granick has been working on it for a long time and tested it extensively.
But I probably could improve on my code and get a better performance in Flash (in which I did the stress-test). The downside is that my code will be full of condition compilation and that would mean the code would become more and more complex.

Why am I sure it will improve, well I cheated and did some flash specific code modifications.
Check the code in github
In my first draft it was just:

var range = _props.get(n);
Reflect.setProperty(_target, n, _easing.ease( time, range.from, (, _duration ) );

and that performed very bad in Flash (if I remember correctly the framerate already dropped after 100 object)
And I updated it to this and that works better… for Flash

var range = _props.get(n);
#if flash
untyped _target[n] = _easing.ease( time, range.from, (, _duration ) ;
Reflect.setProperty(_target, n, _easing.ease( time, range.from, (, _duration ) );

So the question is more do I want to change the code for specific platforms?
For now I am not going to focus on Flash to enhance it’s performance… there is little chance that I will be animating 1000+ objects.

So I will be using it in my own projects and will run into problems that I will fix.
You are welcome to use it as well and report bugs or other improvements.

I’ve update the promotional website: check it here.
You can find the stress-test there, where I compare Go with Actuate.
If you want to add your tweening library, add it here in github.
Download/install instructions can be found here.

Happy tweening.

Animation Haxe Open source / Freeware

Tween engine Go

I have been playing a lot with Haxe and Openfl in the past, but never for work. That changed this week!

Fun stuff!

A while back I noticed some new tweening engines for Haxe. That got me curious: can I build my own tweening engine?

Yes I can!

I named it Go, like “lets Go”.

(And like they say in a track from The Prodigy – Everybody In The Place, lets go )

You can check it out on github:
There you can find more detailed explanation about how it works, so I only will show some basic code here:

Animate a sprite in 1.5 second to x and y position and call function when animation is done, 1.5).x(100).y(200).onComplete(onCompleteHandler, ['hello']);

It was fun to write it, but I haven’t tested in all situations.
I have tested lets.Go on targets flash/cpp/html5/neko.
But I wouldn’t use it in a production situation. It needs more testing.

Let me know what you think!