Console class for AS3 or Haxe

I made a very usefull console class. There is an AS3 version and a Haxe + NME version. Is simple to use and has interesting features you can’t find in other console tools.

The visual representation is similar to consoles that you find in games, such as Quake.


  • Write debug messages and errors to the console. Those messages will be easy to find, and nicely hidden away from regular users. This can speed up the development process.
  • Change the state of your application at runtime, by adding commands to the console.
  • Add “live fields” when you want to display information with a very high time frequency without adding a new line of text on every update, for example when you want to display a number on every frame.
  • Measure the execution time of a piece of code very easily. Results get displayed on the console as a “live field” or as a new text line.
  • Browse the history of previous commands using “up” and “down” cursor keys (like on the OS consoles). The history remains even if you close your application and compile a new version.
  • When you trace an Array, Object/Hash and XML you can see the content, for example: If you write Console.trace(myArray), or trace(myArray) on Haxe, instead of showing “array” it will display the content of the array.
  • All the methods of the class are static, so it’s easy and clean to acess the console anywhere on your code.
    In Haxe the console overrides the native trace method, so you don’t need to import the Console class everywhere if you only need to use the trace.

There are other small features not listed here and new ones comming, you can check the updaets and fixes list here.

How to use it:

  • Starting:





By default “Ctrl + 1” will dislpay the console, you can change that with the parameters of the create() method. If you want to show it by default call show() after the creation:


  • Writing something:


trace(“Hello planet!”);


Console.trace(“Hello planet!”);

  • Creating a command:

Console.addCommand(“sayhello”, callback);


Console.addCommand("sayhello", function(parameters:String):void
    trace("hello! parameters of the command: "+ parameters);

The “patameters” string contains all the user writes after the command, for example if the user write “sayhello hey ho” the string will be “hey ho”. If you write only “sayhello” the string will be null. Use that string to change your application at runtime.

  • Creating a live field:

Console.setLiveDataField(“my data”, myData);


var frameNum:int = 0;
stage.addEventListener(Event.ENTER_FRAME, function(e:Event):void
    Console.setLiveDataField("frames rendered", frameNum);

The first parameter (“my data” in the first example) works as an ID of the live data field.  Creates a live data field if never was created and updates if already exists.
You can create as many live fields as yo want, until you get aut of screen space.

  • Measuring code execution time:

Console.measureTime(“my loop time”);


Console.measureTime("my loop time");
for (element in myObject)
   var createThis:String = "hello";
Console.measureTime("my loop time");

Note the measureTime method is called 2 times, the first time starts measuring time and the second time stops and displays the time elapsed.
The parameter works as an ID, you get the results when you set the same string in both calls.
You can repeat this process with the same ID or a different one on the same runtime.


IMPORTANT FOR HAXE: Version 3.3.2 (or superior) of NME is required, previous versions doesn’t work properly on C++ platform. HTML5 platform is not supported for the moment due to the NME/jeash problem with textField.maxScrollV on HTML5.

This is part of a pack of tools I’m publishing called “fermmmtools”, you can find this class on the “debug” package:

Direct links:

As3 version
Haxe version


HaXe: Multitarget Dictionary class

Sometimes there are things so powerfull that thay have problems just for being powerfull, that’s what happens with HaXe sometimes.
There is not a Dictionary class officialy supported by HaXe, the TypedDictionary class only works on the Flash target.
The reason is because HaXe creates native code, and there is not a generic way in all the native platforms to get an identifier of an object.
But that doesn’t mean we can’t have a a Dictionary class so here it is my version of it, called ObjectHash.
Works good and fast like the flash class, at least on the targets I have tested it: flash, windows/C++ and html5 . If you tested it in another target let me know, I’ll update this.

Download ObjectHash from here.

How to use it:

It has the same syntax of  TypedDictionary. If you need to know how to use the class, learn TypedDitionary.

Differences with NME’s ObjectHash:

  • The NME’s class is more efficient with virtual memory.
  • This class supports more targets than NME’s one.
  • This class works like TypedDictionary or like Dictionary in AS3, when you make a loop you get the keys. NME’s ObjectHash behaves in consistency with HaXe’s Hash, when you make a loop you get values so you need to make a loop using objectHash.keys() to get the keys.

If you are targeting only the NME platforms I recommend you to use that class.

There are some small limitations:

String, Float, Int and Bool types can be set as values but not as keys. Example: myObjectHash.set(myInt, myMovieClip) doesn’t work and myObjectHash.set(myMovieClip, myInt) works. I think is not a big problem since using those basic data types as keys in a object hash is a rare case, I never needed to do that in my years of AS3 development. NME’s version of the class has the same limitation for the moment.