Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the key differences between JavaScript and ActionScript 3?

I know both languages are from the same ECMA-262 standard. It seems that the two are becoming very similar with JavaScript adding event listeners for core Object instances through methods like freeze and seal in EMCAScript-262 5th edition and such. I was wondering what the differences are?

like image 273
Todd Moses Avatar asked Feb 15 '10 19:02

Todd Moses


People also ask

What is the difference between ActionScript and JavaScript?

Both JavaScript and ActionScript are scripting languages, or interpreted languages. The browser (or Flash) interprets the code at runtime. They are not compiled (like C++ or Java). ActionScript is used in Flash applications, while JavaScript can run on almost any web page.

Is ActionScript like JavaScript?

Adobe® ActionScript® 3.0 is a programming language like JavaScript—both are based on ECMAScript. ActionScript 3.0 was released with Adobe® Flash® Player 9 and you can therefore develop rich Internet applications with it in Adobe® Flash® CS3 Professional, Adobe® Flash® CS4 Professional, and Adobe® Flex™ 3.

What ActionScript 3?

ActionScript 3 is an object-oriented programming language originally created by Macromedia Inc., which continued to evolve after being acquired by Adobe Systems. It is a superset of the ECMAScript standard (more widely known as JavaScript) with a stronger focus on classes, interfaces, and objects.

What is the difference using ActionScript 2.0 and ActionScript 3.0 for controlling video?

It's faster, neater and far more recommended than AS2. The main difference is that you can develop flash applications with a much stronger OOP influence than in AS2. AS3 makes it much easier to utilise third party code such as Greensock's Tweenlite, Papervision 3D and box2d.


3 Answers

First of all ActionScript 3 and JavaScript are both defined in ECMA-262 so they have a lot in common. Both languages feature prototype inheritance for instance. It is however not correct that ActionScript fully implements ES4.

ActionScript implements a couple of features that are not defined in ECMA-262 and some -- but definitely not all -- of ES4.

So what does AS3 add to ECMA-262? Those are also the differences to JavaScript:

  • Dynamically and statically typed code
  • Packages, Classes and Interfaces
  • Standard OO inheritance model (not prototype based, statically typed)
  • uint and int datatype
  • E4X (ECMA-357)
  • Type-safe conditional compilation (ES4)
  • Vector.<T> datatype (ES4)

Maybe I have forgotten some features. I am not sure if XML, XMLList etc. are already defined in 262 or came with 357.

The key difference however is the standard library. JavaScript comes with a couple of predefined classes like DOMElement and browser dependent additions. ActionScript has a fairly large standard library with features like video streaming and is consistent over all platforms.

like image 86
Joa Ebert Avatar answered Oct 22 '22 16:10

Joa Ebert


I've been programming in both ActionScript and Javascript, and from a less-technical standpoint, I see two main differences.

1) JavaScript is more powerful. You are allowed to do much more with the language because it does not have a "compiler" or types. There are some great frameworks out there like ExtJS and jQuery that try and simplify things for you, but even with them, you are really allowed to do an amazing amount of damage if you want to.

2) ActionScript is much more confining and hence, much easier to maintain. Adobe did a lot of work to keep you out of the difficult parts of ECMAScript. ECMAScript Objects, prototypal inheritance, and closures are three concepts that you really don't need to understand to program in ActionScript. You just need to understand how to use Adobe's "Class" object.

For simple uses, I prefer JavaScript. However, once the project gets large, it depends who you are coding for. If I had a team of 5 developers programming at a scrappy start-up, I'd choose JavaScript in a heartbeat. However, in the girth of a large corporation, or academia, you might be safer relying on Adobe's platform.

Hope that helps.

like image 22
Stephano Avatar answered Oct 22 '22 16:10

Stephano


One is type Safetly. Actionscript requires that you set a type for all objects, and JavaScript doesn't (for that matter, in JavaScript, one variable may be one type and then immediately set to another type).

Actionscript is object oriented. Although you can sort of have this in JavaScript, Actionscript allows for object inheritance, etc.

like image 5
Gabriel McAdams Avatar answered Oct 22 '22 15:10

Gabriel McAdams