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


About fermmm

AS3 and Haxe developer from Argentina.

8 responses to “Console class for AS3 or Haxe

  1. josuigoa

    Hey fermmm!

    primero gracias por el trabajo que haces y por dejarlo para la comunidad. He descargado la versión haXe de la consola y he tenido que cambiar el nombre de la carpeta de “fermmmtools” a “nmefermmmtools” ya que en el nombre del paquete de las clases aparecía el segundo. Supongo que habrá sido un despiste, por que no he conseguido hacerlo funcionar de otra manera.

    espero haber ayudado

    eskerrik asko!


  2. Hey bro,

    Awesome work. You’ve based some of your code on MLC, which is cool!

    MLC is available under the same license as HSL. (See

    Please add the copyright rule to your project, as required by the license. “Copyright (c) 2009-2012, [your name goes here], Pimm Hogeling, Edo Rivai.”

    If you have any questions, feel free to contact me.

    • Thanks Pimm. I’ve updated it with that copyright text, There is only a copy of the text over the methods and helper classes that are based on MLC. I hope that is ok.

      • It’s highly uncommon (keep it mind that the copyright lines are indications – more like “views” than “models” so to speak), but I think it’s OK.

        However, I’d advise you to add a copyright/license block somewhere anyway, to answer questions such as the one Jonas posted righ under me.

      • thanks for the advice, I’ve updated the class with that information.

  3. I would like to integrate it with my haxe interactive shell project (, since your NME version seems to be much better than mine. However, under what license are you distributing Console.hx?

    • I’ve updated the class with that information:

      You can distribute and modify this class if you preserve the credit texts and links to external websites
      contained in this kind of comments and in the help command.

      If you modify the class you have to modify the credit texts in the following way: “This class version is made by [your name] original version: Fernando Medina.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s