views:

35

answers:

3

I recently realised that Actionscript and Javascript are both implementations of ECMA script. Now I'm wondering what this means in practice.

I have a Flex application written in Actionscript and I'm looking at porting parts of it to Javascript for use in AJAX apps. I have had virtually no exposure to JS so far (not counting occasional onClick handlers in my HTML), so maybe the question is silly. But can I just take my Actionscript classes and use them in JS code?

Naturally, I can't use any of the Flash Player APIs in JS and no DOM in my Flash movie, this much is obvious. Are there other important libraries on either side that can't be used on the other?

+1  A: 

No, not usually. The languages are similar but different. Case-sensitivity of identifiers is one big one (for old versions of ActionScript).

Pointy
correct, except the last sentence. both languages are case sensitive. actionscript 1 wasn't case-sensitive, but then again that's a whole different language than actionscript 3.
back2dos
Ah OK. Thanks for the correction.
Pointy
A: 

There are AS2 and AS3 languages and they are based on different versions of ECMA script and not compatible. Application code on AS2 without flash API is quite similar to js.

Andrey Yatsyk
+1  A: 

AS3 is an ECMA-script dialect at best. It is an implementation of a ECMA-script draft that has been completely dropped. JS is a subset of AS3. However the ActionScript compiler included in the Flex SDK will complain about any untyped variable or function, so you'll have an awfull lot of warnings when you compile.

You should definitely have a look at Jangaroo.

And, as always, my personal advice is for you to slowly migrate (at least the logical parts of your application) to haXe for obvious reasons. You can use as3tohaxe, to facilitate porting.

greetz

back2dos

back2dos
Thanks for pointing me to Jangaroo and haXe. I continue to be amazed at all the language hacks and cross-development tools that programmers come up with.
Hanno Fietz