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.


Importing

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

import

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.

Wildcards

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.

Aliasing

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”.

Leave a Reply

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

WordPress.com Logo

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

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.