Using Haxe: Part 2: Importing

Learning Haxe

Using Haxe

Haxe is a strongly-typed multi-paradigm programming language that also supports cross-platform compiling into many different source and byte-code languages such as ActionScript 3, JavaScript, Java, C++, C#, PHP, Python, Lua, and Node.js.


To work across multiple files, Haxe includes the functionality to import classes from other files.


The import keyword is used to add a class or module to the current file. Through this process, the classes specified are then available for usage.


For loading all classes within a file, Haxe supports wildcard importing. Use of the asterisk after the name of a name and followed by a period imports all of the classes in that file or module. This process only imports one level deep.


Previous to Haxe 3.2.0, the use of the in could be used to import a class through naming its contents another variable. After Haxe 3.20, the keyword as can also be used for the same purpose.

Using “in”
Using “as”

Packages (Namespaces)

Haxe supports using namespaces, shared naming in modules, through the keyword package.

A package is defined through both the keyword and path location. A package named “com.example” would be found in “com/example”.