asJam v0.1.6
asJam, a jam of ActionScript
asJam converts ActionScript 3 source code into Spaceport-compatible JavaScript source code.
asJam is copyright (c) 2011-2012 spaceport.io, Inc.; see LICENSE for details.
Setting up
Binary dependencies:
- Node.JS 0.4.x, 0.6.x
To install:
npm installTo test:
npm test
# or
make testAbout
The converter does not completely convert source code. Some manual work will be required to complete a port of an ActionScript 3 game to Spaceport. The conversion tool is designed to relieve developers of performing the many mundane tasks involved in porting a project to a different language, including:
- Converting AS3 packages into Spaceport modules.
- Converting AS3 classes into Spaceport classes.
- Removing type annotations.
- Inserting
this.in front of member variable and property references. - Inserting
sp.in front of Spaceport classes.
Again, do not expect automatically-converted code to work without modification. Developers will need to test, debug, and modify converted code manually.
Supported features
Classes
- Static properties and constants
- Static methods
Member properties and constants
Note: If you callsuperin a constructor explicitly, properties of superclasses will not be assigned untilsuperis called.Member functions
- Implicit
this.(via aselfalias) super
- Implicit
Constructors
super- Implicit
super
Getter and setter functions
super
Dynamic classes
- Visibility (
private,protected,public) - Internal package classes
Functions
- Optional arguments
- Rest (
...rest) arguments argumentsarray
Packages
import com.coimport com.*- Implicit imports from same package and global package
- Importing a
flashpackage - Partial support for fully-qualified names
Binary operators
+,-,*,/,%=,+=,-=,*=,/=,%=<<,>>,>>>,&,|,^<<=,>>=,>>>=,&=,|=,^===,!=,===,!==>,<,>=,<=&&,||&&=,||=in,instanceof,is,as- Array access
- Comma operator
- Dot access
- Type operator (
:)
Unary operators
+,-++,--~,!new,deletetypeof,void
Ternary operators
?:
Flow control
if,for,while,do-whilefor-in,for-eachwithtry-catch-finallyfunction
Literals
- Number literals (
0.9992,1.42e20,NaN,Infinity,-Infinity) - String literals (
"a\nb") - Array literals (
[ a, b ]) - Object literals (
{ a: b }) - Boolean literals (
true,false) - RegExp literals (
/regexp/gi) null
- Number literals (
Global types
*typeNumber,String,Array,Object,BooleanDate,RegExp
Other features
Vector.<>- Comments (
//and/* */) trace- Casting
Specific conversions
- Use of
flash.system.Securityis removed (with a warning). com.adobe.serialization.JSONand friends are replaced with classes using the native JavaScript (and Flash 11+)JSONclass.
- Use of
Unsupported features
Using the following features may result in non-working code or may not allow a project to be converted at all. In other words, the conversion may be unsuccessful.
The following features will cause a crash and will not convert at all:
XML classes and syntax
::,{},[],+,+=,@,..,.,<>
Proxy classes (
flash.utils.Proxy)- Internal package classes
- Package function exports
- Static constructors
The following features may produce improperly-functioning code and will likely require manual modifications:
- Namespaces
flash.utils.Dictionary- Interfaces
int,uint; all numbers are treated as floating-point numbers except upon declarationClassclass- Metadata tags (e.g.
[Embed]) flash.utils, unless otherwise specified- Naming conflicts requiring fully-qualified names