Haxe Code Cookbook


Overview of Haxe beginner snippets and tutorials.

  • In Haxe, the Array type represents a collection of elements ordered by their index (order number) in the collection.‥

  • This snippet demonstrates use of conditional compilation with custom compiler flags.‥

  • Create a new class with two functions and create a new instance of it.‥

  • Declare function with arguments‥

  • Haxe's enumeration types are algebraic data types. Their primary use is for describing data structures.‥

  • This tutorial demonstrates how to write and compile a Hello World Haxe program. It explains the involved file-format (.hx) and gives a basic explanation of what the Haxe Compiler does with them.‥

  • In Haxe, the List type represents a linked-list of elements.‥

  • This example uses haxe.Http to load external json file using and demonstrates how to handle the result.‥

  • In Haxe, Map (also known as dictionary) allows key to value mapping for arbitrary value types and many key types. ‥

  • Define integers and floats:‥

  • In Haxe a regular expression starts with ~/ and ends with a single / and is of type EReg.‥

  • This snippet shows how to use a string as a variable identifier using reflection.‥

  • These are the Haxe targets that can directly access the filesystem:‥

  • The concept of static extensions is a very poweful concept that gives the possibility of keeping types and objects lightweight, and extending them with functionality only when actually needed. Here we will have a look at how some commonly used methods for basic types are implemented as extension methods, and how you can write your own.‥