Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

 

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

- Operators

- 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 Global Functions Infinity

 

 

-Infinity  

-

-Infinity

-Infinity

 

NaN

-

NaN

NaN

 

undefined

-

undefined

undefined

 

 

 

 

 

 

Global Functions

 

 

 

 

 

Array()

+

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(

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) 

See "diff" page...

isFinite()

+ -

isFinite(value)

isFinite(value)

 

isNaN()

+ -

isNaN(value)

isNaN(value)

 

isXMLName()

+ -

isXMLName(value)

?

See "E4X" page...

  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()

+

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="017d610d-8198-400c-b735-bc1047b07a04"><ac:plain-text-body><![CDATA[

parseInt()

-

parseInt(value, [radix])

parseInt(value, [radix])

 

String()

+ ]]></ac:plain-text-body></ac:structured-macro>

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?

See "diff" page...

uint()

+

uint()

 

uint(value)

uint(value >>> 0)  

See "diff" page...

unescape()

+ -

unescape(value)

unescape(value)

 

Vector()

+ -

result = Vector.<type>(valueArray);

result = /** @type {Array.<type>} */ valueArray;

See "diff" page...

  Let the Closure Compiler handle (check) what is basically a type cast from general Array to a Typed Array.

XML()

+ -

XML(value)

?

See "E4X" page...

  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

See "diff" page...

Boolean

  +

Boolean

Boolean

 

Class

+

-

Code Block
ActionScriptActionScript

package com.example.components
{
public class MyClass
{
    public function MyClass() {}
}
}

Code Block
JavascriptJavascript

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

 

 

 

 

+

-

+

+

 

--

-

--

--

 

/

-

/

/

 

++

-

++

++

 

%

-

%

%

 

*

-

*

*

 

-

See "Class" page...

Date

+

Date

Date

See "diff" page...

DefinitionError

+

DefinitionError

DefinitionError

See "diff" page...

Error

+

Error

Error

See "diff" page...

EvalError

+

EvalError

EvalError

See "diff" page...

Function

+

Function

Function

 

int

+

int

int

See "diff" page...

JSON

+

JSON

JSON

See "diff" page...

Math

+

Math

Math

 

Namespace

+

Namespace

Namespace

See "diff" page...

Number

+

Number

Number

 

Object

+

Object

Object

See "diff" page...

QName

+

QName

See "E4X" page...

 

RangeError

+

RangeError

RangeError

See "diff" page...

ReferenceError

+

ReferenceError

ReferenceError

See "diff" page...

RegExp

+

RegExp

RegExp

See "diff" page...

SecurityError

+

SecurityError

SecurityError

See "diff" page...

String

+

String

String

See "diff" page...

SyntaxError

+

SyntaxError

SyntaxError

See "diff" page...

TypeError

+

TypeError

TypeError

See "diff" page...

uint

+

uint

uint

See "diff" page...

URIError

+

URIError

URIError

See "diff" page...

Vector

+

Vector

See "diff" page...

 

VerifyError

+

VerifyError

VerifyError

See "diff" page...

XML

+

XML

See "E4X" page...

 

XMLList

+

XMLList

See "E4X" page...


 

 

 

 

 

Arithmetic

 

 

 

 

+

+

+

+

 

--

+

--

--

 

/

+

/

/

 

++

+

++

++

 

%

+

%

%

 

*

+

*

*

 

-

+

-

-

 

 

 

 

 

 

Arithmetic compound assignment

 

 

 

 

+=

+

+=

+=

 

/=

+

/=

/=

 

%=

+

%=

%=

 

*=

+

*=

*=

 

-=

+

-=

-=

-

-

-

-

 

 

 

 

 

 

Arithmetic compound assignment Assignment

 

 

 

 

+ =

- +

+ = +

=

 

/=  

-  

/=   /=

 

 

%= Bitwise

-  

%=   %=

 

 

*= &

- +

& *=
*=

&

 

-= << -

+

-= << -=

<<

  

~

+  
 

~

  ~

 

Assignment |

+  
 

|

  |

 

= >>

+ -

=

>>

>>

 

>>>

+

>>>

>>>

 

^

+

^

^ =

 

 

 

 

 

 

Bitwise compound assignment

 

 

 

 

&=

- +

&=

&=

 

<<=

- +

<<=

<<=

 

~

-

~

~

 

|=

- +

|=

|=

 

>>=

- +

>>=

>>=

 

>>>=

- +

>>>=

>>>=

 

^=

- +

^=

^=

 

 

 

 

 

 

Bitwise compound assignment Comment

 

 

 

 

/**/

+

/**/

/**/

&=

-

&=

&=

  <<

= //

- +

<<=

//

// <<=

 

|=  

-  

|=   |=

 

 

>>= Comparison

-  

>>=   >>=

 

 

>>> ==

- +

>>> == >>>

==

 

^= >

- +

^= > ^=

>

  

>=

  +  

>=

  >=

  Comment

!=

  +  

!=

!=  

 

<

+

<

<

/**/

-

/**/

/**/

  /

/ <=

- +

//

<=

<= //

  

===

  +

 

===

===  

 

Comparison

 

 

 

 

!==

- +

!==

!==

 

>  

-  

>   >

 

 

>= Logical

-  

>=   >=

 

 

&&

+

&&

&&

 

&& !=

- +

! x &&= != y

See "diff" page...

 

! <

- +

< ! <

!

  <

= ||

- +

<=

||

|| <=

 

||= ==

- +

x ||= ==

===

 

!==

-

!==

!==

y

See "diff" page...

 

 

 

 

 

 

 

Logical Other

 

 

 

  &

[] &

- +

&&

[]

[] &&

 

&&= as

-

x &&= y

x = x && y

Excellent suggestion from Fank: Keep It Simple, Stupid ;-)

!

-

!

!

 

||

-

||

||

 

||=

-

x ||= y

x = x || y

KISS, again.

 

 

 

 

 

Other

 

 

 

 

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="21035643-50d6-4e17-a3f5-49569871d5da"><ac:plain-text-body><![CDATA[

[]

-

[]

[]

 

]]></ac:plain-text-body></ac:structured-macro>

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

 

 

 

 

+

-

+

+

 

+=

-

+=

+=

 

+

as

See "diff" page...

 

,

+

,

,

 

?:

+

(value) ? true : false;

(value) ? true : false;

 

delete

+

delete

delete

 

.

+

.

.

 

in

+

in

in

 

instanceof

+

instanceof

instanceof

See "diff" page...

is

+

is

?


::

+

::

?

 

new

+

new

new

 

{}

+

{}

{}

 

()

+

()

()

 

/

+

/

/

 

:

+

:

See "diff" page...

 

typeof

+

typeof

typeof

See "diff" page...

void

+

void

void

 

 

 

 

 

 

String

 

 

 

 

+

+

+

+

 

+=

+

+=

+=

 

"

+

"

"

 

 

 

 

 

 

XML

 

 

 

 

@

-

@

See "E4X" page...


{}

-

{}

See "E4X" page...

 

[]

-

[]

See "E4X" page...

 

+

-

+

See "E4X" page...


+=

-

+=

See "E4X" page...


delete

-

delete

See "E4X" page...


..

-

..

See "E4X" page...


.

-

.

See "E4X" page...


()

-

()

See "E4X" page...


<>

-

<>

See "E4X" page...

"

-

"

"

 

 

 

 

 

 

XML Statements

 

 

 

 

break

@ +

- break

@ break

?

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?

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="684f2a0f-28c1-4551-8ccc-90de0075d184"><ac:plain-text-body><![CDATA[

[]

-

[]

?

See '@' above, and: these are the same as used in AS array literals, Mike: can you make the distinction?

]]></ac:plain-text-body></ac:structured-macro>

+

-

+

?

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

 

 

 

 

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

 

 

 

 

 

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

See "diff" page...

 

if

+

if

if

 

label

+

label

label

 

return

+

return

return

 

super

+

super([arg1, ..., argN]);
super.method([arg1, ..., argN]);

See "diff" page... 

 

switch

+

switch

switch

 

throw

+

throw

throw

 

try...catch...finally

+

try...catch...finally

try...catch...finally

 

while

+

while

while

 

with

+

with

with

 

 

interface

 

 

 

  namespace

Attribute Keywords

 

 

 

 

package dynamic

  +

 

dynamic

See "diff" page...  

 

set final

  +

 

 

 

final

See "diff" page... var

  

internal

  +

 

internal

See "diff" page...  

  

native

 

 

[not user accessible]

Directives

 

  

override

  +

default xml namespace

override

See "diff" page...  

  

private

  +

import

 

private

See "diff" page...  

  

protected

include +

 

protected

See "diff" page...  

  

public

use namespace +

public

See "diff" page...


static

+

static

See "diff" page...

 

 

 

 

 

 

 

 

  Namespaces

 

 

  

Definition keywords

AS3

 

 

 

 

flash_proxy

 

 

 

 

object_proxy

 

 

 

 

 

 

 

 

 

Primary expression keywords

 

 

 

 

false

 

 

 

 

null

 

 

 

 

this

 

 

 

 

true

 

 

 

 

 

 

 

 

 

OLD

 

 

 

 

Inheriting

 

Code Block
ActionScriptActionScript

package com.example.components{
import org.apache.flex.Button;

public class MyClass extends Button
{
	public function MyClass()
	{
		super();
	}
}
}

Code Block
JavascriptJavascript

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);

 

... (rest) parameter

+

...rest

See "diff" page...


class

+

class

See "Class Implementations" page...

 

const

+

const

See "diff" page...

 

extends

+

extends

See "diff" page...

 

function

+

function

function

 

get

+

get

See "diff" page...

 

implements

+

implements

See "diff" page...

 

interface

+

interface

See "diff" page...

 

namespace

+

namespace

See "diff" page...

 

package

+

package

See "diff" page...

 

set

+

set

See "diff" page...

 

var

+

var

var

 

 

 

 

 

 

Directives

 

 

 

 

default xml namespace

-

default xml namespace

See "E4X" page...

 

import

+

import

See "diff" page...

 

include

-

include

See "diff" page...

 

use namespace

-

use namespace

See "diff" page...

 

 

 

 

 

 

Namespaces

 

 

 

 

AS3

-

?

?

See "diff" page...

flash_proxy

-

?

?

See "diff" page...

object_proxy

-

?

?

See "diff" page...

 

 

 

 

 

Primary expression keywords

 

 

 

 

false

+

false

false

 

null

+

null

null

 

this

+

this

See "diff" page...

 

true

+

true

true

 

 

Implementing

 

TBD

TBD

 

Inheriting + Implementing

 

TBD

TBD

 

 

 

 

 

 

Fields

 

 

 

 

private

 

Code Block

private var _myVar:String = "";
Inside the constructor function:
Code Block

/**
 * @private
 * @type {string}
 */
this._myVar = '';

 

protected

 

This is how far I got today ;-)

 

 

public

 

 

 

 

Global Constants