HaxeLive
HaxeLive is a library that currently supports OpenFL in bringing live preview capabilities.
Note SimpleButton
's in OpenFL does not function correctly as implemented in our code. We are working on whether or not this is an OpenFL issue or specific to the codebase and find a solution. For now, the code works in version 3.4, so if you need SimpleButton's to function properly, that's the version we recommend to use.
Note If using the hxWidgets backend, please use the repository found here.
Need Assistance?
You can submit a post on the official Colour ID forums for technical assistance setting up or acquiring help on HaxeLive or anything related to it.
To Install
You can install in one of two ways:
haxelib install hxlive
Will install the latest stable version.
haxelib git https://github.com/ColourID/HaxeLive.git
Will install the latest development version. This may or may not be stable, and there is no guarantee it will work 100%.
Using this library
This library parses JSON-formatted files into generated scenes that can be live-previewed for fast prototyping, as well as redistributed and reused for your projects.
OpenFL Backend
In Main.hx, we have the following code to help us with the live preview capabilities:
import hxlive.Live;
import openfl.display.Sprite;
class Main extends Sprite
{
private var live:Live;
public function new()
{
super();
live = new Live("info/config.json");
addChild(live);
}
}
config.json
is required to make configuration settings with HaxeLive. This is now required, as it will help to provide a more robust way of switching between scenes without needing to recompile your application to test them. The configuration file is only used with the Live
class. Nothing has changed with SceneGen
so your codebase should remain the same in that regard.
An example of the configuration file may look something like this:
{
"file": "info/MyBase.json"
}
All of the parsing, scene generation and previewing is done automatically.
Once you have designed an interface you like, you can use the SceneGen
class, followed by the generate
function that takes the parsed data from a JSON file.
hxWidgets Backend
When using the hxWidgets backend, you are required to manually click the 'Update' button found at the bottom of the Window in order for the interface to be updated with the latest changes of the JSON file(s). This is because a solution has not yet been found to enable immediate feedback.
The hxWidgets backend does not yet have an Exporter.
You can test the example found under tests/widgets
. On Windows, you will need to copy the *.dll files from the hxWidgets repository under wxWidgets/windows/[MSVC version]/[32 or 64-bit]/dll/
into the bin
directory. The Build.bat
file found in the test folder can be used to copy these dll files, you will need to modify it to point to the repository and the correct folder.
Warning
If, on Windows, hxWidgets does not build your application, one of the reasons may be because the Build.xml file in the root of the repository is not choosing the correct MSVC compiler version that would replace the ${vc}
with the appropriate value. This can occur if you have more than one version of the compiler installed on your computer. To fix this, simply modify the Build.xml file and replace the ${vc}
value with the version of the compiler you want to use.
Exporting
You can now export what you see on the screen into usable Haxe source code to use in your projects.
To do this, simply press CTRL+E on any C++ target and a dialog will appear allowing you to select a location you wish to save your Haxe code to. Once you have chosen a location and hit save, the user interface will be exported to Haxe code.
Why Export? Exporting your JSON file into usable Haxe code will make it easier for you to add logic to the scenes you create, instead of using the SceneGen
class. It also removes the tedious task of setting up all of these objects yourself.
Documentation
Because there is a lot of information regarding this library, please consult the wiki.
Submitting a Pull Request
You can submit a pull request for one of these reasons:
- To submit a patch for a bug fix or improvement.
- To submit a feature for a different backend.
For improvements, this must improve only the functionality of the Live class, as changes in API will need to be modified in all other backends to match.
When creating a backend, match the API as seen in the current backend for openfl
. This will make it easier for users to use a different backend without needing to modify too much of their codebase.
All pull requests should be licensed under MIT for convenience.