Getting Started (JS)

Developing Javascript code is really easy with haXe. Let's see our first HelloWorld sample :

Put this class into a file named Test.hx and create the file compile.hxml in the same directory with the following content :

To compile, you can simply double-click on the compile.hxml file (or run the command haxe compile.hxml). If an error occur, it will be displayed. If everything went smoothly like it should, this will produce a file named test.js that can be embedded into an HTML page such as this one :

If you put since code into a file named test.html and open it with your webbrowser, it should display Hello World with information about file and line the trace occured. Please note that a div block is needed to display the haXe Javascript traces.

Using Alert
The possibility to display some text is to use alert. Modify Test.hx with the following content :

Compile and open the test.html. It should display a window message box displaying the current location URL.

Watch the available APIs from /api/js/Lib.