As the name suggests, hx3ds is a port of as3ds for haXe and is now available at lib.haxe.org. hx3ds only supports the flash player 10 target, as it makes extensive use of the Vector class. If you need data structures that compile across all platforms, take a look at colhx instead.

Here’s a list of new features:

  • orders of magnitude faster
  • collections now support clone() and shuffle() operations
  • object pooling framework
  • revised graph, tree and linked list classes
  • memory manager for the virtual memory API (more on this soon)

I’m planning to port the new features back to as3ds as soon as it leaves beta.

The best thing is that hx3ds runs considerable faster than as3ds. This is good news since data structures are usually used at a low level in an application and so the speed increase should be noticeable instantly. Here are some numbers for the two dimensional array:array2 as3ds vs hx3ds
This difference stems mainly from haXe using proper integer opcodes, method inlining and generics. Let me shortly explain the last point: Say you want to write a custom List class and store the data within a Vector using composition. In ActionScript this would look like this:

package {
    public class MyList {
        private var _data:Vector.<Object>;

You are forced to use a dynamic Vector because you don’t know what the users will throw in. There’s nothing wrong with it, but you can’t expect any performance wonders. As usual, some hard facts:
array vs vector
In haXe the former code example would look like this:

class MyList<T> implements haxe.rtti.Generic {
    private var _data:flash.Vector<T>;
var list:MyList<Int> = new MyList<Int>();

By implementing the Generic interface you tell the compiler to create unique classes for each type parameter, gaining both type safety and speed. After compilation the result would look like this:

class MyList_Int implements haxe.rtti.Generic {
    private var _data:flash.Vector<Int>;


  1. Great stuff! haXe makes every ActionScript developer drool in envy! I hope FDT will get haXe support fast! If this trend continues haXe will be the AS of the future.

  2. Did you know that the data structures don’t compile on CS4 ?

    It’s related with the interfaces, the getters and setters. It seems it’s a bug of CS4. That would be great if you could update the package in order it compile with CS4.

    The kind of errors we get :

    1044: Interface method get size in namespace de.polygonal.ds:Collection not implemented by class de.polygonal.ds:HashMap.

  3. Note : it’s related to this bug :


  4. I’ll check that. Honestly, I have never really tested the data structures package with the Flash IDE compiler.

  5. Hi, we had the same problems with our datastructures package and for us it was a matter of refactoring and removing the internal classes. This makes for more classes in a package, but it compiled again under cs4.
    see http://www.dpdk.nl/opensource/internal-classes-confuse-cs4-compiler


  1. [...] Polygonal labs, maker of some of the best demos, information and tools for AS3 since inception updated the killer AS3 Data Structures for Game Developers and ported it to haXe. [...]

  2. [...] compilation, inlining, advanced typing a lot more. The biggest claim to fame HaXe has is a big performance margin over AS3, as well as better memory management [...]

Get Adobe Flash player