Skip to content

Defining scripted types

ashley edited this page Aug 9, 2026 · 3 revisions

You can define scripted types in the following ways...

Scripts

You can simply declare types within your scripts!

class Message {
	public var text:String;
	
	public function new(text:String) { this.text = text; }
	
	public function alert():String { trace(text); }
}

new Message('hello world!').alert(); // hello world!

The code example above should work correctly in a script.
The only caveat to doing this is that script defined types (maybe obviously) can't be imported in any other scripts by default.

Modules

Modules work (almost) exactly the same you would expect in Haxe!

Currently, you can define the following types in scripts...

Support for currently unsupported types is planned to be introduced in the near future.
Defining fields at module level is also supported within scripted modules!

Look at the Loading scripts page to learn how to implement modules in your project.

Clone this wiki locally