| Test Available In FalconJx (+/-)? | ActionScript | JavaScript + Closure annotation | Notes |
---|---|---|---|---|
Global Constants |
|
|
|
|
Infinity | + | Infinity | Infinity |
|
-Infinity | + | -Infinity | -Infinity |
|
NaN | + | NaN | NaN |
|
undefined | + | undefined | undefined |
|
|
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 | |||||||
Global Functions | - | 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) | int(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) |
| |||||||
parseFloat() | + - | parseFloat(value) | parseFloat(value) |
| |||||||
parseInt() | + | <ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="1dfe47f3-7440-42aa-90a3-94d1e9c8ad10"><ac:plain-text-body><![CDATA[ | parseInt() | - | parseInt(value, [radix]) | parseInt(value, [radix]) |
| ]]></ac:plain-text-body></ac:structured-macro> | |||
String() | + | String() | - | String(value) | String(value) | See "Array" function note. | |||||
trace() | + - | trace(...values) | console.log trace(...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() | | uint(value) | uint(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) | ? | See "E4X" page... Use 'goog.dom.xml'? | |||||||
|
|
|
|
| |||||||
Classes |
|
|
|
| |||||||
ArgumentError | - + | ArgumentError | Error | ArgumentError | See "diff" page... 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 | + | - Code Block | | ActionScript | ActionScript | ||||||
package com.example.components
{
public class MyClass
{
public function MyClass() {}
}
}
| |||||||||||
Code Block | Javascript | Javascript | |||||||||
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 |
|
|
|
| |||||||
+ | - | + | + |
| |||||||
-- | - | -- | -- |
| |||||||
/ | - | / | / |
| |||||||
++ | - | ++ | ++ |
| |||||||
- | |||||||||||
Date | + | Date | Date | ||||||||
DefinitionError | + | DefinitionError | DefinitionError | ||||||||
Error | + | Error | Error | ||||||||
EvalError | + | EvalError | EvalError | ||||||||
Function | + | Function | Function |
| |||||||
int | + | int | int | ||||||||
JSON | + | JSON | JSON | ||||||||
Math | + | Math | Math |
| |||||||
Namespace | + | Namespace | Namespace | ||||||||
Number | + | Number | Number |
| |||||||
Object | + | Object | Object | ||||||||
QName | + | QName |
| ||||||||
RangeError | + | RangeError | RangeError | ||||||||
ReferenceError | + | ReferenceError | ReferenceError | ||||||||
RegExp | + | RegExp | RegExp | ||||||||
SecurityError | + | SecurityError | SecurityError | ||||||||
String | + | String | String | ||||||||
SyntaxError | + | SyntaxError | SyntaxError | ||||||||
TypeError | + | TypeError | TypeError | ||||||||
uint | + | uint | uint | ||||||||
URIError | + | URIError | URIError | ||||||||
Vector | + | Vector |
| ||||||||
VerifyError | + | VerifyError | VerifyError | ||||||||
XML | + | XML |
| ||||||||
XMLList | + | XMLList | |||||||||
|
|
|
|
| |||||||
Arithmetic |
|
|
|
| |||||||
+ | + | + | + |
| |||||||
-- | + | -- | -- |
| |||||||
/ | + | / | / |
| |||||||
++ | + | ++ | ++ |
| |||||||
% | + | % | - | % | % |
| |||||
* | + - | * | * |
| |||||||
- - | + | - | - |
| |||||||
|
|
|
|
| |||||||
Arithmetic compound assignment |
|
|
|
| |||||||
+= | - + | += | += |
| |||||||
/= | - + | /= | /= |
| |||||||
%= | - + | %= | %= |
| |||||||
*= | - + | *= | *= |
| |||||||
-= - | + | -= | -= |
| |||||||
|
|
|
|
| |||||||
Assignment |
|
|
|
| |||||||
= | - + | = | = |
| |||||||
|
|
|
|
| |||||||
Bitwise |
|
|
|
| |||||||
& | - + | & | & |
| |||||||
<< | + - | << | << |
| |||||||
~ | + - | ~ | ~ |
| |||||||
| | + - | | | | |
| |||||||
>> | + - | >> | >> |
| |||||||
>>> | + - | >>> | >>> |
| |||||||
^ | + - | ^ | ^ |
| |||||||
|
|
|
|
| |||||||
Bitwise compound assignment |
|
|
|
| |||||||
&= | - + | &= | &= |
| |||||||
<<= | - + | <<= | <<= |
| |||||||
|= | - + | |= | |= |
| |||||||
>>= | - + | >>= | >>= |
| |||||||
>>>= | - + | >>>= | >>>= |
| |||||||
^= | - + | ^= | ^= |
| |||||||
|
|
|
|
| |||||||
Comment |
|
|
|
| |||||||
/**/ | - + | /**/ | /**/ |
| |||||||
// | - + | // | // |
| |||||||
|
|
|
|
| |||||||
Comparison |
|
|
|
| |||||||
== | - + | == | == |
| |||||||
> | - + | > | > |
| |||||||
>= | - + | >= | >= |
| |||||||
!= | - + | != | != |
| |||||||
< | - + | < | < |
| |||||||
<= | - + | <= | <= |
| |||||||
=== | - + | === | === |
| |||||||
!== | - + | !== | !== |
| |||||||
|
|
|
|
| |||||||
Logical |
|
|
|
| |||||||
&& | - + | && | && |
| |||||||
&&= | - + | x &&= | ? | y | ? | ||||||
! | - + | ! | ! |
| |||||||
|| | - + | || | || |
| |||||||
||= | - + | x ||= | ? | y | ? | ||||||
|
|
|
|
| |||||||
Other |
|
|
|
| |||||||
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="2757b580-24d0-453a-9822-b9980c002e1c"><ac:plain-text-body><![CDATA[ | [] | - | [] | [] |
| ]]></ac:plain-text-body></ac:structured-macro> | |||||
as | - | as | ? | I think we need a utility function | |||||||
, |
|
|
|
| |||||||
?: |
|
|
|
| |||||||
delete |
|
|
|
| |||||||
. |
|
|
|
| |||||||
in |
|
|
|
| |||||||
instanceof |
|
|
|
| |||||||
is |
|
|
|
| |||||||
:: |
|
|
|
| |||||||
new |
|
|
|
| |||||||
{} |
|
|
|
| |||||||
() |
|
|
|
| |||||||
/ |
|
|
|
| |||||||
[] | + | [] | [] |
| |||||||
as | + | as |
| ||||||||
, | + | , | , |
| |||||||
?: | + | (value) ? true : false; | (value) ? true : false; |
| |||||||
delete | + | delete | delete |
| |||||||
. | + | . | . |
| |||||||
in | + | in | in |
| |||||||
instanceof | + | instanceof | instanceof | ||||||||
is | + | is | ? | ||||||||
:: | + | :: | ? |
| |||||||
new | + | new | new |
| |||||||
{} | + | {} | {} |
| |||||||
() | + | () | () |
| |||||||
/ | + | / | / |
| |||||||
: | + | : |
| ||||||||
typeof | + | typeof | typeof | ||||||||
void | + | void | void |
| |||||||
: |
|
|
|
| |||||||
typeof String |
|
|
|
| |||||||
void + | + | + | + |
| |||||||
|
|
|
|
| |||||||
String |
|
|
|
| |||||||
+ |
|
|
|
| |||||||
+= | + | += | += |
| |||||||
" | + | " | " |
| |||||||
|
|
|
|
|
|
| |||||
| XML |
|
|
|
| ||||||
@ | - |
|
| @ | |||||||
{} | - |
| {} |
| |||||||
[] | |||||||||||
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="a3772690-9ce1-4801-b120-c7f7c59e5d0e"><ac:plain-text-body><![CDATA[ | [] |
|
|
|
| ]]></ac:plain-text-body></ac:structured-macro> | |||||
+ |
|
|
|
| |||||||
+= |
|
|
|
| |||||||
delete |
|
|
|
| |||||||
- | [] |
| |||||||||
+ | - | + | |||||||||
+= | - | += | |||||||||
delete | - | delete | |||||||||
.. | - | .. | |||||||||
. | - | . | |||||||||
() | - | () | |||||||||
<> | - | <> |
| ||||||||
|
| . |
|
| |||||||
Statements | () |
|
|
| |||||||
break | <> + | break | break |
| |||||||
case | + | case | case |
| |||||||
continue | Statements + | continue | continue |
| |||||||
default | break + | default | default |
|
| ||||||
case |
|
|
|
| |||||||
continue |
|
|
|
| |||||||
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 |
| ||||||
if | + | if | if |
| |||||||
label | + | label | label |
| |||||||
return | + | return | return |
| |||||||
super |
|
|
| + | super([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 |
| |||||||
final | + |
| final |
| |||||||
internal | + |
| internal |
| |||||||
native |
| [not user accessible] |
|
| |||||||
override | + |
| override |
| |||||||
private | + |
| private |
| |||||||
protected | + |
| protected |
| |||||||
public | + |
|
| public | |||||||
static | + |
| static |
| |||||||
|
|
|
|
| |||||||
Definition keywords |
|
|
|
| |||||||
... (rest) parameter |
| + | ...rest | ||||||||
class | + | class |
|
|
| class |
|
| |
| |
const | + |
| const |
| |||||||
extends | + |
| extends |
| |||||||
function | + | function | function |
| |||||||
get | + |
| get |
| |||||||
implements | + |
| implements |
| |||||||
interface | + |
| interface |
| |||||||
namespace | + |
| namespace |
| |||||||
package | + |
| package |
| |||||||
set | + |
| set |
| |||||||
var | + | var | var |
| |||||||
|
|
|
|
| |||||||
Directives |
|
|
|
| |||||||
default xml namespace | - |
| default xml namespace |
| |||||||
import | + |
| import |
| |||||||
include | - |
| include |
| |||||||
use namespace | - |
| use namespace |
| |||||||
|
|
|
|
| |||||||
Namespaces |
|
|
|
| |||||||
AS3 | - | ? |
|
| ? | ||||||
flash flash_proxy | - | ? |
| ? | |||||||
object_proxy | - | ? |
| ? | |||||||
|
|
|
|
| |||||||
Primary expression keywords |
|
|
|
| |||||||
false |
|
|
|
| |||||||
null |
|
|
|
| |||||||
this |
|
|
|
| |||||||
true |
|
|
|
| |||||||
|
|
|
|
| |||||||
OLD |
|
|
|
| Inheriting |
| |||||
Code Block | ActionScript | ActionScript | |||||||||
package com.example.components{
import org.apache.flex.Button;
public class MyClass extends Button
{
public function MyClass()
{
super();
}
}
}
| |||||||||||
Code Block | Javascript | Javascript | |||||||||
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);
|
| ||||||||||
|
| ||||||||||
Primary expression keywords |
|
|
|
| |||||||
false | + | false | false |
| |||||||
null | + | null | null |
| |||||||
this | + | this |
| ||||||||
true | + | true | true |
| |||||||
| |||||||||||
Implementing |
| TBD | TBD |
| |||||||
Inheriting + Implementing |
| TBD | TBD |
| |||||||
|
|
|
|
| |||||||
Fields |
|
|
|
| private |
|
Code Block |
---|
private var _myVar:String = "";
|
Code Block |
---|
/**
* @private
* @type {string}
*/
this._myVar = '';
|
protected
This is how far I got today ;-)
public
Global Constants