What is the difference between ActionScript 2.0 and ActionScript 3.0

Besides the library changes, Actionscript 3 is compiled for and run on a completely different virtual machine (AVM2), which was re-written from the ground up. It reportedly executes compiled AS3 code up to 10 times faster than code script compiled for the AVM1 virtual machine.

You should check out this doc for a list of differences between AS2 and AS3 as they can't be explained any better on SO :)

answered May 24, 2011 at 7:04 Demian Brecht Demian Brecht 21.3k 5 5 gold badges 43 43 silver badges 47 47 bronze badges

And a non-technical addendum: AS2 is the legacy language, AS3 is the current language. New features that get added to the Flash player generally aren't usable from AS2.

Commented May 25, 2011 at 9:23

In AS3 you can structure and organise your application a lot more strategically. 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.

In AS2 you would have to use prototype to messily achieve what a class can do for you in AS3. Example:

AS2 prototype:

MovieClip.prototype.flip = function():Void

AS3 class that can be used as a base class for all your MovieClips:

package < import flash.display.MovieClip; public class MyMovieClip extends MovieClip < public function flip():void < rotation += 180; >> > 

Though there is more code in creating your own class, you can now extend this class and simply call flip() from within it to run the flip() method. In AS2, you would have to be in the same scope as your MovieClip.prototype.flip() function to access it, which can cause a mess.

Here's the AS2 and AS3 comparison for creating a MovieClip, adding it to the stage and then making use of your flip() function:

AS3:

var mc:MyMovieClip = new MyMovieClip(); mc.flip(); addChild(mc); 

AS2::

MovieClip.prototype.flip = function():Void < this._rotation += 180; >var mc:MovieClip = attachMovie("your_library_mc", "newname", this.getNextHighestDepth()); mc.flip(); 
answered May 24, 2011 at 6:54 39.4k 19 19 gold badges 96 96 silver badges 163 163 bronze badges

As a couple of other people have stated AS2 and AS3 are different languages and even run on on different virtual machine in the flash player, AVM and AVM2 (Actionscript Virtual Machine).

However, that most of the AS2 code has direct AS3 equivalents and in the case of timeline code that names are usually the same (e.g. gotoAndPlay, stop, etc.). You can find a handy cheat sheet here: http://actionscriptcheatsheet.com/downloads/as3cs_migration.pdf Generally if there's no AS3 equivalent to what you have in your AS2 there's a better and more robust way instead.

There's also a book call 'The ActionScript 3.0 Migration Guide' that you might want to check out too.

Also you can make AS2 and AS3 code talk to each other through a LocalConnection. There're plenty of how-to's about this on the web.