Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between ActionScript 2.0 and ActionScript 3.0

What are the main differences between the versions?

like image 456
Ramu Avatar asked May 24 '11 05:05

Ramu


2 Answers

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

like image 143
Demian Brecht Avatar answered Nov 15 '22 06:11

Demian Brecht


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
{
    this._rotation += 180;
}

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();
like image 34
Marty Avatar answered Nov 15 '22 06:11

Marty