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 Unknown macro: {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 |
Need utility class and cast a regular Error object to that, for the sake of the Closure Compiler? |
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 |
- |
|
|
|
RangeError |
|
|
|
|
ReferenceError |
|
|
|
|
RegExp |
|
|
|
|
SecurityError |
|
|
|
|
String |
|
|
|
|
SyntaxError |
|
|
|
|
TypeError |
|
|
|
|
uint |
|
|
|
|
URIError |
|
|
|
|
Vector |
|
|
|
|
VerifyError |
|
|
|
|
XML |
|
|
|
|
XMLList |
|
|
|
|
|
|
|
|
|
Arithmetic |
|
|
|
|
+ |
|
|
|
|
-- |
|
|
|
|
/ |
|
|
|
|
++ |
|
|
|
|
% |
|
|
|
|
* |
|
|
|
|
- |
|
|
|
|
|
|
|
|
|
Arithmetic compound assignment |
|
|
|
|
+= |
|
|
|
|
/= |
|
|
|
|
%= |
|
|
|
|
*= |
|
|
|
|
-= |
|
|
|
|
|
|
|
|
|
Assignment |
|
|
|
|
= |
|
|
|
|
|
|
|
|
|
Bitwise |
|
|
|
|
& |
|
|
|
|
<< |
|
|
|
|
~ |
|
|
|
|
| |
|
|
|
|
>> |
|
|
|
|
>>> |
|
|
|
|
^ |
|
|
|
|
|
|
|
|
|
Bitwise compound assignment |
|
|
|
|
&= |
|
|
|
|
<<= |
|
|
|
|
|= |
|
|
|
|
>>= |
|
|
|
|
>>>= |
|
|
|
|
^= |
|
|
|
|
|
|
|
|
|
Comment |
|
|
|
|
/../ |
|
|
|
|
// |
|
|
|
|
|
|
|
|
|
Comparison |
|
|
|
|
== |
|
|
|
|
> |
|
|
|
|
>= |
|
|
|
|
!= |
|
|
|
|
< |
|
|
|
|
<= |
|
|
|
|
=== |
|
|
|
|
!== |
|
|
|
|
|
|
|
|
|
Logical |
|
|
|
|
&& |
|
|
|
|
&&= |
|
|
|
|
! |
|
|
|
|
|| |
|
|
|
|
||= |
|
|
|
|
|
|
|
|
|
Other |
|
|
|
|
[] |
|
|
|
|
as |
|
|
|
|
, |
|
|
|
|
?: |
|
|
|
|
delete |
|
|
|
|
. |
|
|
|
|
in |
|
|
|
|
instanceof |
|
|
|
|
is |
|
|
|
|
:: |
|
|
|
|
new |
|
|
|
|
{} |
|
|
|
|
() |
|
|
|
|
/ |
|
|
|
|
: |
|
|
|
|
typeof |
|
|
|
|
void |
|
|
|
|
|
|
|
|
|
String |
|
|
|
|
+ |
|
|
|
|
+= |
|
|
|
|
" |
|
|
|
|
|
|
|
|
|
XML |
|
|
|
|
@ |
|
|
|
|
{} |
|
|
|
|
[] |
|
|
|
|
+ |
|
|
|
|
+= |
|
|
|
|
delete |
|
|
|
|
.. |
|
|
|
|
. |
|
|
|
|
() |
|
|
|
|
<> |
|
|
|
|
|
|
|
|
|
Statements |
|
|
|
|
break |
|
|
|
|
case |
|
|
|
|
continue |
|
|
|
|
default |
|
|
|
|
do...while |
|
|
|
|
else |
|
|
|
|
for |
|
|
|
|
for...in |
|
|
|
|
for each...in |
|
|
|
|
if |
|
|
|
|
label |
|
|
|
|
return |
|
|
|
|
super |
|
|
|
|
switch |
|
|
|
|
throw |
|
|
|
|
try...catch...finally |
|
|
|
|
while |
|
|
|
|
with |
|
|
|
|
|
|
|
|
|
Attribute Keywords |
|
|
|
|
dynamic |
|
|
|
|
final |
|
|
|
|
internal |
|
|
|
|
native |
|
|
|
|
override |
|
|
|
|
private |
|
|
|
|
protected |
|
|
|
|
public |
|
|
|
|
static |
|
|
|
|
|
|
|
|
|
Definition keywords |
|
|
|
|
... (rest) parameter |
|
|
|
|
class |
|
|
|
|
const |
|
|
|
|
extends |
|
|
|
|
function |
|
|
|
|
get |
|
|
|
|
implements |
|
|
|
|
interface |
|
|
|
|
namespace |
|
|
|
|
package |
|
|
|
|
set |
|
|
|
|
var |
|
|
|
|
|
|
|
|
|
Directives |
|
|
|
|
default xml namespace |
|
|
|
|
import |
|
|
|
|
include |
|
|
|
|
use namespace |
|
|
|
|
|
|
|
|
|
Namespaces |
|
|
|
|
AS3 |
|
|
|
|
flash_proxy |
|
|
|
|
object_proxy |
|
|
|
|
|
|
|
|
|
Primary expression keywords |
|
|
|
|
false |
|
|
|
|
null |
|
|
|
|
this |
|
|
|
|
true |
|
|
|
|
|
|
|
|
|
OLD |
|
|
|
|
Inheriting |
|
package com.example.components{ import org.apache.flex.Button; public class MyClass extends Button { public function MyClass() { super(); } } } |
goog.provide('com.example.components.MyClass'); goog.require('org.apache.flex.Button'); /** * @constructor * @extends {org.apache.flex.Button} */ com.example.components.MyClass = function() { goog.base(this); }; goog.inherits(com.example.components.MyClass, org.apache.flex.Button); |
|
Implementing |
|
TBD |
TBD |
|
Inheriting + Implementing |
|
TBD |
TBD |
|
|
|
|
|
|
Fields |
|
|
|
|
private |
|
private var _myVar:String = ""; |
Inside the constructor function: /** * @private * @type {string} */ this._myVar = '';
|
|
protected |
|
This is how far I got today ;-) |
|
|
public |
|
|
|
|
Global Constants |
|
|
|
|