| Module API v1.0 | |
| Versioning system | |
| Version numbers | Every version number in SamHaXe has three parts separated by dots(.) |
| Version request strings | Similar to version numbers but you can omit every part (major, minor, bugfix) |
| Interface independent variables/ | |
| Variables | |
| interfaces | List of supported module interface versions. |
| description | Short descrition string about the import module. |
| Functions | |
| initModule | Initializes the module. |
| initInterface | Requests a specific interface version from the import module. |
| main | Main entry point of the module. |
| Interface dependent variables/ | |
| Functions | |
| check | Validates a resource XML node. |
| import | Imports assets described by a resource XML node. |
| help | Returns a long help string about XML tags supported by the module. |
| The process of importing an asset | Detailed description of the import process. |
| 1st step: module - namespace URI assignment | First we should assign some namespace URI to the module. |
| 2nd step: namespace definition | Define a namespace in the resource description file. |
| 3rd step: asset import XML tag | Specify the appropriate XML tag in the resource description file. |
| 4th step: XML syntax checking | The import module checks the syntax of XML node. |
| 5th step: importing the asset | The import module processes the XML node and returns the appropriate SWF tags. |
| Version numbers | Every version number in SamHaXe has three parts separated by dots(.) |
| Version request strings | Similar to version numbers but you can omit every part (major, minor, bugfix) |
Every version number in SamHaXe has three parts separated by dots(.)
So for example the version string “1.2.14” corresponds to
The major and minor versions give the interface version. The bugfix version number is used to address different versions of a module which share a common interface but are differ in some sort of functionality.
Similar to version numbers but you can omit every part (major, minor, bugfix)
Version request strings are used to query an interface from some import module which has specific properties. For example if you need a module interface which has interface version “1.2” but you don’t care about the bugfix version, you can use “1.2” as the version request string. In this case the highest available bugfix version is queried.
| Variables | |
| interfaces | List of supported module interface versions. |
| description | Short descrition string about the import module. |
| Functions | |
| initModule | Initializes the module. |
| initInterface | Requests a specific interface version from the import module. |
| main | Main entry point of the module. |
Short descrition string about the import module.
String
The description is printed by --module-list command line option. See Command line options
Requests a specific interface version from the import module.
static function initInterface(version: String, moduleService: Dynamic): Void
| version | The version request string |
| moduleService | A collection of functions passed to the module. In module API version 1.0 it’s a ModuleService_1_0 instance. |
If some error occurs during interface initialization the function throws a String as the error message.
Imports assets described by a resource XML node.
function import(node: NsFastXml, options: Hash<String>): Array<SWFTag>
| node | The XML node describing the asset. |
| options | The hash of options passed to the module in command line. See Command line options for details. |
The array of generated SWF tags.
Detailed description of the import process.
Let’s assume we want to import logo.png into our asset library. It’s an image file so we’ll examine the Image module.
| 1st step: module - namespace URI assignment | First we should assign some namespace URI to the module. |
| 2nd step: namespace definition | Define a namespace in the resource description file. |
| 3rd step: asset import XML tag | Specify the appropriate XML tag in the resource description file. |
| 4th step: XML syntax checking | The import module checks the syntax of XML node. |
| 5th step: importing the asset | The import module processes the XML node and returns the appropriate SWF tags. |
First we should assign some namespace URI to the module. This can be done through samhaxe.conf.xml. See Configuration
<module name="Image" uri="http://mindless-labs.com/samhaxe/modules/Image"/>
SamHaXe reads the configuration file and stores the module -> URI assignments but doesn’t loads or initializes any module yet.
Define a namespace in the resource description file.
<shx:resources ... xmlns:img="http://mindless-labs.com/samhaxe/modules/Image#1.0" />
var lm = neko.vm.Module.local(); lm.setExport(SamHaXeModule.INIT_INTERFACE, initInterface);
var module = new Image(); module.moduleService_1_0 = cast moduleService; lm.setExport(SamHaXeModule.IMPORT_FUN_1_0, module.import_image_1_0);
The import module checks the syntax of XML node.
SamHaXe calls the exported check function with the parsed XML node.
The import module processes the XML node and returns the appropriate SWF tags.
SamHaXe calls the exported import function with the parsed XML node.