A table showing how each ActionScript language 'feature' is should be translated to Google Closure Tools assisted JavaScript by the FalconJS Compiler.
Using these AS3 references:
- Global Constants, Functions and Classes
- Statements, Keywords and Directives
Using Google Closure annotations:
- Annotating JavaScript for the Closure Compiler
Table quick navigation:
- coming soon ;-)
Legend for Javascript column color usage:
Black: JavaScript matches ActionScript
Red: solution not agreed upon
Blue: solution looks good, need consencus to approve (use Comments or Notes column)
Green: solution agreed upon
|
Test Available In FlexJS (+/-)? |
ActionScript |
JavaScript + Closure annotation |
Notes |
---|---|---|---|---|
Global Constants |
|
|
|
|
Infinity |
- |
Infinity |
Infinity |
|
-Infinity |
- |
-Infinity |
-Infinity |
|
NaN |
- |
NaN |
NaN |
|
undefined |
- |
undefined |
undefined |
|
|
|
|
|
|
Global Functions |
|
|
|
|
Array() |
- |
Array(...values) |
Array(...values) |
Frank's comment: https://cwiki.apache.org/confluence/display/FLEX/AS+to+JS+translation+table?focusedCommentId=30744800#comment-30744800 |
Boolean() |
- |
Boolean(value) |
Boolean(value) |
See "Array" function note. |
decodeURI() |
- |
decodeURI(value) |
decodeURI(value) |
|
decodeURIComponent() |
- |
decodeURIComponent(value) |
decodeURIComponent(value) |
|
encodeURI() |
- |
encodeURI(value) |
encodeURI(value) |
|
encodeURIComponent() |
- |
encodeURIComponent(value) |
encodeURIComponent(value) |
|
escape() |
- |
escape(value) |
escape(value) |
|
int() |
- |
int(value) |
(value >> 0) |
|
isFinite() |
- |
isFinite(value) |
isFinite(value) |
|
isNaN() |
- |
isNaN(value) |
isNaN(value) |
|
isXMLName() |
- |
isXMLName(value) |
? |
There is no matching implementation in JavaScript. We may need to build a utility function to cover this one. |
Number() |
- |
Number(value) |
Number(value) |
See "Array" function note. |
Object() |
- |
Object(value) |
Object(value) |
In ActionScript, calling 'Object(value)' returns 'value' (since all values are objects). Given that, does it make sense to just write 'value' in JavaScript and let the Closure Compiler "cast" it? |
parseFloat() |
- |
parseFloat(value) |
parseFloat(value) |
|
parseInt() |
- |
parseInt(value, [radix]) |
parseInt(value, [radix]) |
|
String() |
- |
String(value) |
String(value) |
See "Array" function note. |
trace() |
- |
trace(...values) |
console.log(...values) |
We may need a utility function to wrap 'console.log', as not all browsers have debugging enable, and calling to a non-existent 'console' object will cause an error. Maybe something like Jangaroo's 'trace' implementation? |
uint() |
|
uint(value) |
(value >>> 0) |
|
unescape() |
- |
unescape(value) |
unescape(value) |
|
Vector() |
- |
result = Vector.<type>(valueArray); |
result = /** @type {Array.<type>} */ valueArray; |
Let the Closure Compiler handle (check) what is basically a type cast from general Array to a Typed Array. |
XML() |
- |
XML(value) |
? |
Use 'goog.dom.xml'? |
XMLList() |
|
XMLList(value) |
? |
Use 'goog.dom.xml'? |
|
|
|
|
|
Classes |
|
|
|
|
ArgumentError |
- |
ArgumentError |
Error |
Need utility class and cast a regular error object to that, for the sake of the Closure Compiler? |
arguments |
- |
arguments |
arguments |
|
Array |
- |
Array |
Array |
Not sure if all properties and methods of AS Array class map to the JS Array class. |
Boolean |
|
Boolean |
Boolean |
|
Class |
- |
package com.example.components { public class MyClass { public function MyClass() {} } } |
goog.provide('com.example.components.MyClass'); /** * @constructor */ com.example.components.MyClass = function() {}; |
|
Date |
- |
Date |
Date |
The JS class seems to be missing all the properties that the AS class offers. The methods on both classes match, AFAICT. |
DefinitionError |
- |
DefinitionError |
Error |
Need utility class and cast a regular Error object to that, for the sake of the Closure Compiler? |
Error |
- |
Error |
Error |
There is no 'errorID' property on the JS Error class |
EvalError |
- |
EvalError |
EvalError |
Not sure if all JS VM implementations support this... |
Function |
- |
Function |
Function |
|
int |
- |
int |
Number |
|
JSON |
- |
JSON |
JSON |
How about support for "older" browsers? Do we provide "if not JSON, add custom JSON to window object"? |
Math |
- |
Math |
Math |
|
Namespace |
- |
Namespace |
? |
Do we need a utility class? |
Number |
- |
Number |
Number |
|
Object |
- |
Object |
Object |
"setPropertyIsEnumerable" not available on JS Object.prototype... |
QName |
- |
QName |
? |
Part of the E4X implementation in AS... No such beast in JS, so maybe we look at "goog" or even a native utility class? |
RangeError |
- |
RangeError |
RangeError |
Not sure if all JS VM implementations support this... |
ReferenceError |
- |
ReferenceError |
ReferenceError |
Not sure if all JS VM implementations support this... |
RegExp |
- |
RegExp |
RegExp |
Does the regular expression "syntax" of both implementations match? |
SecurityError |
- |
SecurityError |
Error |
Need utility class and cast a regular Error object to that, for the sake of the Closure Compiler? |
String |
- |
String |
String |
Not sure if all properties and methods of AS String class map to the JS String class. |
SyntaxError |
- |
SyntaxError |
SyntaxError |
Not sure if all JS VM implementations support this... |
TypeError |
- |
TypeError |
TypeError |
Not sure if all JS VM implementations support this... |
uint |
- |
uint |
Number |
Does the Number object provide all "functionality" of an AS uint? If so, we're good, I think... |
URIError |
- |
URIError |
URIError |
Not sure if all JS VM implementations support this... |
Vector |
- |
Vector |
/** @type {Array.<type>} */ Array |
Since a Vector is "nothing more" than a typed Array, we can use Closure annotation to 'force' the Closure Compiler to treat it as such. |
VerifyError |
- |
VerifyError |
Error |
Need utility class and cast a regular Error object to that, for the sake of the Closure Compiler? |
XML |
- |
XML |
? |
Part of the E4X implementation in AS... No such beast in JS, so maybe we look at "goog" or even a native utility class? |
XMLList |
- |
XMLList |
? |
Part of the E4X implementation in AS... No such beast in JS, so maybe we look at "goog" or even a native utility class? |
|
|
|
|
|
Arithmetic |
|
|
|
|
+ |
- |
+ |
+ |
|
-- |
- |
-- |
-- |
|
/ |
- |
/ |
/ |
|
++ |
- |
++ |
++ |
|
% |
- |
% |
% |
|
* |
- |
* |
* |
|
- |
- |
- |
- |
|
|
|
|
|
|
Arithmetic compound assignment |
|
|
|
|
+= |
- |
+= |
+= |
|
/= |
- |
/= |
/= |
|
%= |
- |
%= |
%= |
|
*= |
- |
*= |
*= |
|
-= |
- |
-= |
-= |
|
|
|
|
|
|
Assignment |
|
|
|
|
= |
- |
= |
= |
|
|
|
|
|
|
Bitwise |
|
|
|
|
& |
- |
& |
& |
|
<< |
- |
<< |
<< |
|
~ |
- |
~ |
~ |
|
| |
- |
| |
| |
|
>> |
- |
>> |
>> |
|
>>> |
- |
>>> |
>>> |
|
^ |
- |
^ |
^ |
|
|
|
|
|
|
Bitwise compound assignment |
|
|
|
|
&= |
- |
&= |
&= |
|
<<= |
- |
<<= |
<<= |
|
|= |
- |
|= |
|= |
|
>>= |
- |
>>= |
>>= |
|
>>>= |
- |
>>>= |
>>>= |
|
^= |
- |
^= |
^= |
|
|
|
|
|
|
Comment |
|
|
|
|
/**/ |
- |
/**/ |
/**/ |
|
// |
- |
// |
// |
|
|
|
|
|
|
Comparison |
|
|
|
|
== |
- |
== |
== |
|
> |
- |
> |
> |
|
>= |
- |
>= |
>= |
|
!= |
- |
!= |
!= |
|
< |
- |
< |
< |
|
<= |
- |
<= |
<= |
|
=== |
- |
=== |
=== |
|
!== |
- |
!== |
!== |
|
|
|
|
|
|
Logical |
|
|
|
|
&& |
- |
&& |
&& |
|
&&= |
- |
x &&= y |
x = x && y |
Excellent suggestion from Fank: Keep It Simple, Stupid ;-) |
! |
- |
! |
! |
|
|| |
- |
|| |
|| |
|
||= |
- |
x ||= y |
x = x || y |
KISS, again. |
|
|
|
|
|
Other |
|
|
|
|
[] |
- |
[] |
[] |
|
as |
- |
as |
? |
I think we need a utility function |
, |
- |
, |
, |
|
?: |
- |
(value) ? true : false; |
(value) ? true : false; |
|
delete |
- |
delete |
delete |
|
. |
- |
. |
. |
|
in |
- |
in |
in |
|
instanceof |
- |
instanceof |
instanceof |
We need to check the "goog" way of inheritance for correctness of the JS 'instanceof' and see if the Closure annotation method for implementing "Interfaces" covers the functionality of AS 'instanceof'. |
is |
- |
is |
? |
I think we need a utility function |
:: |
- |
:: |
? |
|
new |
- |
new |
new |
|
{} |
- |
{} |
{} |
|
() |
- |
() |
() |
|
/ |
- |
/ |
/ |
Is the regular expression syntax the same between the two (AS and JS) implementations? |
: |
- |
: |
multiple solutions, context dependent |
To "strongly" type JS, we use the Google Closure annotations. These are JSDoc block that go with function or variable declarations and give the Closure Compiler hints as to the type of variables, arguments and return values. |
typeof |
- |
typeof |
typeof |
Only the "xml" type is not supported on the JS side (nor are the data types that go with it, XML and XMLList) |
void |
- |
void |
void |
Note: this applies to 'void' as an operator, not the "data type" |
|
|
|
|
|
String |
|
|
|
|
+ |
- |
+ |
+ |
|
+= |
- |
+= |
+= |
|
" |
- |
" |
" |
|
|
|
|
|
|
XML |
|
|
|
|
@ |
- |
@ |
? |
Part of the E4X implementation in AS... No such beast in JS, so maybe we look at "goog" or even a native utility class? |
{} |
- |
{} |
? |
See '@' above, and: these are the same as used in AS object literals, Mike: can you make the distinction? |
[] |
- |
[] |
? |
See '@' above, and: these are the same as used in AS array literals, Mike: can you make the distinction? |
+ |
- |
+ |
? |
See '@' above, and: this is the same as used the AS concatenation operator: Mike, can you make the distinction? |
+= |
- |
+= |
? |
See '@' above, and: this is the same as used the AS concatenation operator: Mike, can you make the destinction? |
delete |
- |
delete |
? |
See '@' above, and: this is the same as used the AS delete operator: Mike, can you make the distinction? |
.. |
- |
.. |
? |
Part of the E4X implementation in AS... No such beast in JS, so maybe we look at "goog" or even a native utility class? |
. |
- |
. |
? |
See '@' above, and: this is the same as used the AS access operator: Mike, can you make the distinction? |
() |
- |
() |
? |
See '@' above, and: this is the same as used the AS grouping operator: Mike, can you make the destinction? |
<> |
- |
<> |
? |
Part of the E4X implementation in AS... No such beast in JS, so maybe we look at "goog" or even a native utility class? |
|
|
|
|
|
Statements |
|
|
|
|
break |
- |
break |
break |
|
case |
- |
case |
case |
|
continue |
- |
continue |
continue |
|
default |
- |
default |
default |
|
do...while |
- |
do...while |
do...while |
|
else |
- |
else |
else |
|
for |
- |
for |
for |
|
for...in |
- |
for...in |
for...in |
|
for each...in |
- |
for each...in |
for each...in |
|
if |
- |
if |
if |
|
label |
- |
label |
label |
|
return |
- |
return |
return |
|
super |
- |
super([arg1, ..., argN]); |
goog.base(this, [arg1, ..., argN]); |
|
switch |
- |
switch |
switch |
|
throw |
- |
throw |
throw |
|
try...catch...finally |
- |
try...catch...finally |
try...catch...finally |
|
while |
- |
while |
while |
|
with |
- |
with |
with |
|
|
|
|
|
|
Attribute Keywords |
|
|
|
|
dynamic |
- |
dynamic |
no annotation needed |
All JS 'classes' are dynamic by nature, so there's no need for this keyword? |
final |
- |
final |
no annotation needed |
Is this a runtime attribute, or is it handled at compile time? If the latter, we can just leave it out as attempts to subclass this type are handled (blocked) on the AS side anyway? |
internal |
- |
internal |
no annotation needed |
Same as with 'final'? |
native |
- |
[not user accessible] |
no annotation needed |
|
override |
- |
override function myFunction() |
/** |
|
private |
- |
private |
/** |
|
protected |
- |
protected |
/** |
|
public |
- |
public |
no annotation needed |
All JS entities are public by nature, so there's no need for this keyword? |
static |
- |
static |
? |
|
|
|
|
|
|
Definition keywords |
|
|
|
|
... (rest) parameter |
- |
...rest |
[leave out] |
All JS functions allow an arbitrary number of arguments, so there's no need for this keyword? |
class |
- |
class |
function |
Please see "Class" in the Class section, above. |
const |
- |
const |
/** |
|
extends |
- |
extends MyBaseClass |
/** Unknown macro: {MyBaseClass}
|
|
function |
- |
function |
function |
|
get |
- |
get |
? |
|
implements |
- |
implements MyInterface |
/** |
|
interface |
- |
interface |
/** |
|
namespace |
- |
namespace |
? |
|
package |
- |
package my.package |
goog.provides("my.package.MyClass") |
|
set |
- |
set |
? |
|
var |
- |
var |
var |
|
|
|
|
|
|
Directives |
|
|
|
|
default xml namespace |
- |
default xml namespace |
? |
Part of the E4X implementation in AS... No such beast in JS, so maybe we look at "goog" or even a native utility class? |
import |
- |
import my.package.MyOtherClass |
goog.requires("my.package.MyOtherClass"); |
|
include |
- |
include |
? |
|
use namespace |
- |
use namespace |
? |
|
|
|
|
|
|
Namespaces |
|
|
|
|
AS3 |
- |
? |
? |
I'm not familiar with this in AS, so can't figure out what, if anything, might 'replace' this in JS. |
flash_proxy |
- |
? |
? |
I'm not familiar with this in AS, so can't figure out what, if anything, might 'replace' this in JS. |
object_proxy |
- |
? |
? |
I'm not familiar with this in AS, so can't figure out what, if anything, might 'replace' this in JS. |
|
|
|
|
|
Primary expression keywords |
|
|
|
|
false |
- |
false |
false |
|
null |
- |
null |
null |
|
this |
- |
this |
Any method in which "this" is referenced should have the following in it's JSDoc block |
|
true |
- |
true |
true |
|
|
|
|
|
|