I've stumbled upon Jangaroo, and it seems to provide what i need. The problem is that to use it the docs say that i need to setup maven.
I really have a single function, so all that is a bit of an overkill.
The ideal solution would be something similar to the Telerik Code Converter(http://converter.telerik.com), but for AS3.
I just updated the documentation on how to use Jangaroo as a command line tool:
https://github.com/CoreMedia/jangaroo-tools/wiki/Stand-Alone-Compiler
After following steps 1 through 6, you can compile your single class like so:
Note that the generated JavaScript file
GACodec.js
only works together with the jangaroo runtime. The Wiki page continues with instructions on how to end up with a working Webapp. For your class, you just have to unpackjangaroo-runtime.jar
:Then, you can run your class from a tiny HTML file that looks like so:
When trying out your code, I noticed that it needs a minor change to work: Jangaroo does not generate implicit initialization code for typed local variables. There are at least two lines in your code where an integer variable is declared but not initialized explicitly. ActionScript would set it to
0
, but Jangaroo does not. Anyway, it is better style to do explicit initialization, and if you do so, i.e. in your source code replaceby
as far as I can tell, it seems works!
Last thing, I find using Maven easier than installing the Jangaroo SDK, since you just have to install Maven once and it takes care of all needed downloads and makes updating to the latest Jangaroo version a breeze: Just increase the Jangaroo version number in your
pom.xml
, and Maven takes care of everything else.