The API facilitates communications with the Neko VM that is running the application back-end code, from and to a GUI that is created with either the Adobe Flash IDE, Flex 1, 1.5 or 2.0, MTASC or any other technology capable of compiling ActionScript to SWF.
The API comes in two flavors: ActionScript 2 and ActionScript 3. After installing SWHX, the API is located in your haXelib library folder. To get its exact location, issue:
haxelib path swhx
from your command-line. Append /api/actionscript/AS2 or /api/actionscript/AS3 for to obtain the full path. To use the API with your GUI project, make sure to add this path to your projects class search path.
static public function init(base: Object): Api
Invoking swhx.Api.int(...) is required to enable the application back-end to be able to reach the GUI. The base argument is the object instance (or static object) that will be used by the API to resolve function invokation from the back-end on.
// In ActionScript 3 static public function call(path: String,... args) : Object; // In ActionScript 2 static public function call([uses this.arguments]);
Use this method to invoke a function on the Neko VM. The path argument specifies which function should be invoked on the back-end. The additional arguments get passed as arguments to the invoked function.
Methods invoked using call are invoked synchronously. This implies that the GUI will be frozen until the invoked function returns.
call‘s actual return type will be the ActionScript equivalent of the Neko type returned by the back-end.