Eventually all these libs will become haxelibs, however, currently in their alpha form they do not even contain a haxelib.json
file (for dependencies, etc) and therefore can only be used by downloading the source and using the haxelib dev
command or by directly using the git versions using the haxelib git
command (recommended). Eg:
haxelib git haxeui-core https://github.com/haxeui/haxeui-core
haxelib dev haxeui-flambe path/to/expanded/source/archive
If however you already have an existing application, then incorporating HaxeUI into that application is straightforward:
In order to use haxeui with an existing `Flambe` application you must add these libraries to your `flambe.yaml` configuration file as part of the `haxe_flags` attribute. Eg:# Additional flags to pass to the Haxe compiler.
# haxe_flags: -lib nape -D foobar
haxe_flags: -swf-header 800:600:60:FFFFFF -lib haxeui-core -lib haxeui-flambe
Note: Currently you must also include haxeui-core
explicitly during the alpha, eventually haxelib.json
files will exist to take care of this dependency automatically.
// Wind up all platform-specific stuff
System.init();
// Load up the compiled pack in the assets directory named "bootstrap"
var manifest = Manifest.fromAssets("bootstrap");
var loader = System.loadAssetPack(manifest);
loader.get(onAssetsLoaded);
Initialising the toolkit requires you to add this single line somewhere before you start to actually use HaxeUI in your application but after you have loaded the Flambe
asset pack:
private static function onAssetsLoaded(pack:AssetPack) {
Toolkit.init( {
assetPack: pack // let the toolkit know which asset pack we are using
});
}
Once the toolkit is initialised you can add components using the methods specified here.
As well as using the generic Screen.instance.addComponent
, it is also possible to add components directly using a Flambe
entity. Eg:
System.root.addChild(new Entity().add(main));
Toolkit.init({
assetPack: pack // the asset pack to work with
});