Wiki Markup |
---|
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)
...
new Array(...values)
...
There is no matching method in Javascript. Do we use a utility method that returns an array, or do we just use a 'new' Array object?
...
Boolean()
...
-
...
Boolean(value)
...
new 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)
...
new Number(value)
...
See "Array" function note.
...
Object()
...
-
...
result = Object(value) ;
...
Wiki Markup result = /*\* @type {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)
...
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="509eb984-027f-4db6-ae55-79bd2d6eefd4"><ac:plain-text-body><![CDATA[
...
parseInt()
...
-
...
parseInt(value, [radix])
...
parseInt(value, [radix])
...
...
]]></ac:plain-text-body></ac:structured-macro>
...
String()
...
-
...
String(value)
...
new 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.
...
uint()
...
...
uint(value)
...
(value >>> 0)
...
...
unescape()
...
-
...
unescape(value)
...
unescape(value)
...
...
Vector()
...
-
...
result = Vector.<type>(valueArray);
...
Wiki Markup 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
...
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
...
...
...
...
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="b99dd6e1-f227-4120-af18-a36adade3478"><ac:plain-text-body><![CDATA[
...
[]
...
...
...
...
...
]]></ac:plain-text-body></ac:structured-macro>
...
as
...
...
...
...
...
,
...
...
...
...
...
?:
...
...
...
...
...
delete
...
...
...
...
...
.
...
...
...
...
...
in
...
...
...
...
...
instanceof
...
...
...
...
...
is
...
...
...
...
...
::
...
...
...
...
...
new
...
...
...
...
...
{}
...
...
...
...
...
()
...
...
...
...
...
/
...
...
...
...
...
:
...
...
...
...
...
typeof
...
...
...
...
...
void
...
...
...
...
...
...
...
...
...
...
String
...
...
...
...
...
+
...
...
...
...
...
+=
...
...
...
...
...
"
...
...
...
...
...
...
...
...
...
...
XML
...
...
...
...
...
@
...
...
...
...
...
{}
...
...
...
...
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="adcec363-0be1-4491-97fc-43602509e67e"><ac:plain-text-body><![CDATA[
...
[]
...
...
...
...
...
]]></ac:plain-text-body></ac:structured-macro>
...
+
...
...
...
...
...
+=
...
...
...
...
...
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
...
...
---- Using these AS3 references: \- [Global Constants, Functions and Classes|http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/package-detail.html#constantSummary] \- [Operators|http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/operators.html] \- [Statements, Keywords and Directives|http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/statements.html] Using Google Closure annotations: \- [Annotating JavaScript for the Closure Compiler|https://developers.google.com/closure/compiler/docs/js-for-compiler] ---- Table quick navigation: \- coming soon \;-) ---- Legend for Javascript column color usage: Black: JavaScript matches ActionScript {color:#ff0000}Red{color}: solution not agreed upon {color:#3366ff}Blue{color}: solution looks good, need consencus to approve (use Comments or Notes column) {color:#339966}Green{color}: solution agreed upon || || Test Available In FlexJS (+/-)? || ActionScript || JavaScript + Closure annotation || Notes || | *Global Constants* | | | | | | Infinity | \- | Infinity \\ | {color:#000000}Infinity{color} \\ | | | \-Infinity | \- | \-Infinity \\ | {color:#000000}\-Infinity{color} \\ | | | NaN | \- | NaN | NaN \\ | | | undefined | \- | undefined | undefined \\ | | | | | | | | | *Global Functions* | | | | | | Array() \\ | \- | Array(...values) | {color:#3366ff}Array(...values){color}\\ | Frank's comment: https://cwiki.apache.org/confluence/display/FLEX/AS+to+JS+translation+table?focusedCommentId=30744800#comment-30744800 | | Boolean() | \- | Boolean(value) \\ | {color:#3366ff}Boolean(value){color}\\ | 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) | {color:#3366ff}(value >> 0){color}\\ | | | isFinite() | \- | isFinite(value) | isFinite(value) | | | isNaN() | \- | isNaN(value) | isNaN(value) | | | isXMLName() | \- | isXMLName(value) \\ | {color:#ff0000}?{color} | There is no matching implementation in JavaScript. We may need to build a utility function to cover this one. | | Number() | \- | Number(value) | {color:#3366ff}Number(value){color} | See "Array" function note. | | Object() | \- | Object(value) | {color:#3366ff}Object(value){color}\\ | 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) | {color:#3366ff}String(value){color} | See "Array" function note. | | trace() | \- | trace(...values) | {color:#ff0000}console.log(...values){color} | 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) | {color:#3366ff}(value >>> 0){color} | | | unescape() | \- | unescape(value) \\ | unescape(value) \\ | | | Vector() | \- | result = Vector.<type>(valueArray); | {color:#ff0000}result = /*\* @type {color}{Array.<type>} {color:#ff0000}\*/ valueArray;{color} | Let the Closure Compiler handle (check) what is basically a type cast from general Array to a Typed Array. | | XML() \\ | \- | XML(value) | {color:#ff0000}?{color} | Use 'goog.dom.xml'? | | XMLList() | | XMLList(value) | {color:#ff0000}?{color} | Use 'goog.dom.xml'? \\ | | | | | | | | *Classes* \\ | | | | | | ArgumentError | \- | ArgumentError | {color:#ff0000}Error{color}\\ | Need utility class and cast a regular error object to that, for the sake of the Closure Compiler? | | arguments | \- | arguments | arguments | | | Array | \- | Array | {color:#3366ff}Array{color} | Not sure if all properties and methods of AS Array class map to the JS Array class. | | Boolean | | Boolean | {color:#000000}Boolean{color}\\ | | | Class | \- | {code:ActionScript} package com.example.components { public class MyClass { public function MyClass() {} } } {code} | {code:Javascript} goog.provide('com.example.components.MyClass'); /** * @constructor */ com.example.components.MyClass = function() {}; {code} | | | Date | \- | Date | {color:#ff0000}Date{color} | The JS class seems to be missing all the properties that the AS class offers. The methods on both classes match, AFAICT. | | DefinitionError | \- | DefinitionError | {color:#ff0000}Error{color} | Need utility class and cast a regular Error object to that, for the sake of the Closure Compiler? \\ | | Error | \- | Error | {color:#ff0000}Error{color} | There is no 'errorID' property on the JS Error class | | EvalError | \- | EvalError | {color:#ff0000}EvalError{color} | Need utility class and cast a regular Error object to that, for the sake of the Closure Compiler? \\ | | Function | \- | Function | Function | | | int | \- | int | {color:#3366ff}Number{color} | | | JSON | \- | JSON | {color:#3366ff}JSON{color} | How about support for "older" browsers? Do we provide "if not JSON, add custom JSON to window object"? | | Math | \- | Math | Math | | | Namespace | \- | Namespace | {color:#ff0000}?{color} | 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 | | {code:ActionScript} package com.example.components{ import org.apache.flex.Button; public class MyClass extends Button { public function MyClass() { super(); } } } |
...
{code} | {code: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); |
...
...
Implementing
...
...
TBD
...
TBD
...
...
Inheriting + Implementing
...
...
TBD
...
TBD
...
...
...
...
...
...
...
Fields
...
...
...
...
...
private
...
...
{code} | | | Implementing | | TBD | TBD | | | Inheriting + Implementing | | TBD | TBD | | | | | | | | | *Fields* | | | | | | private | | \\ \\ {code} private var _myVar:String = ""; |
...
{code} | Inside the constructor function: \\ \\ {code} /** * @private * @type {string} */ this._myVar = ''; |
...
...
protected
...
...
This is how far I got today ;-)
...
...
...
public
...
...
...
...
...
Global Constants
...
...
...
...
{code} | |
| protected | | This is how far I got today \;-) | | |
| public | | | | |
| Global Constants | | | | | |