0

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.

durron597
  • 31,968
  • 17
  • 99
  • 158
beppe9000
  • 1,056
  • 1
  • 13
  • 28
  • Well, you can either set up maven or convert the function by hand (if you don't know JS, find someone who does, it doesn't really matter whether they know AS3, it's close enough that anyone who knows JS should be able to read it). The thing about Telerik is that converting between C# and VB is fairly trivial, since both are based on the .NET platform. When converting from AS3 to JavaScript, you have to deal with the fact that AS3 has a substantially different runtime library. – jjm Nov 29 '14 at 17:10
  • @beepe9000 `Javascript` and ActionScript `AS3` are both based on the `ECMAScript` Specification. So it shouldn't really be difficult. But where is your code? – helloflash Nov 29 '14 at 17:22
  • I taught that the code was not relevant within this question, since I am asking for advice on how to use Jangaroo without having to use maven. In my case I am trying to port a scrambling algorithm to VB.Net. I am not very practical in AS3, less than I am in JS, so I opted to use Js to simplify the task of re-coding to Vb. However this is the package: http://pastebin.com/6dRUqpr0 – beppe9000 Nov 29 '14 at 18:03
  • I found this: https://github.com/CoreMedia/jangaroo-tools/wiki/Stand-Alone-Compiler – beppe9000 Nov 30 '14 at 14:50
  • I appreciate you have a correct/satisfactory answer but I saw the **[Pastebin code](http://pastebin.com/6dRUqpr0)** and that code is not really usable as it is written (did you decompile it from some copy-protected or ofuscated code?). Anycase it's not "normal" actionscript and better if you try to find some real AS3, C# or VB shuffling tutorial code rather than going with this "messed-up" AS3 to JScript then to VB.net as you are planning. Just saying to save you time... – VC.One Dec 02 '14 at 08:20
  • Yes, I have been working on both fronts. ;) – beppe9000 Dec 03 '14 at 00:35

1 Answers1

1

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:

mkdir joo\classes
jooc -v -g SOURCE -classpath %JOOLIBS%\jangaroo-runtime.jar -sourcepath . -d joo\classes GACodec.as

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 unpack jangaroo-runtime.jar:

"%JAVA_HOME%\bin\jar" -xf %JOOLIBS%\jangaroo-runtime.jar

Then, you can run your class from a tiny HTML file that looks like so:

<script src="joo/jangaroo-runtime.module.js"></script>
<script>
  joo.classLoader.import_("GACodec");
  joo.classLoader.complete(function() {
    alert(new GACodec().encode("FOOBAR!"));
  });
</script>

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 replace

var i:int;

by

var i:int = 0;

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.

YetAnotherFrank
  • 386
  • 1
  • 8