project/ ├── src/ │ └── Main.hx │ ├── bin/ │ └── js/ │ └── index.html │ └── build.hxml2. Insert the following code into the
src/Main.hx
file:class Main { static function main() { trace("Haxe is great!"); } }3. Insert the following code into the
bin/js/index.html
file:<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title></title> </head> <body> <script src="main.js"></script> </body> </html>4. Add the following build configuration into the
build.hxml
file:-cp src -main Main -js bin/js/main.jsThe configuration above specifies that your source code is stored in
src/
, that your main Haxe file is src/Main.hx
, and that you want Haxe to output the JavaScript source code into bin/js/main.js
.
Browse the Haxe API website for the core Haxe APIs that you can use in your project.
You can use JavaScript-specific APIs in addition to the core Haxe APIs.
Browse the haxelib website for community-developed libraries that you can add to your project.
You can install haxelib libraries globally by running haxelib install <library>
.
You can specify that your project uses a haxelib by adding -lib <library>
to the build.hxml
file.
Build the Haxe project by running haxe build.hxml
in a console in the project directory.
This compiles your .hx
source code to JavaScript code which you can run and debug next.
After compiling your project with Haxe, you can open and debug the index.html
file in your browser. Open the developer tools in the browser to see log output. If you haven't changed the example from step 3, you should see the 'Haxe is great!' log message.
If you need help with anything, visit the vibrant Haxe community and simply ask for help with the details of your project. We have a helpful and active community and you should get your answers quickly!