ActionScript 2 versus ActionScript 3

Jul 26, 01:40 PM |

Are you working in as2 and considering change to as3? Or just started learning Flash and don’t know what ActionScript version to use? This article will help you decide.

If someone tells you it’s not possible to develop larger applications with as2, they are not right. I had been working in as2 some eight years and have made many applications with it, including several fairly large games and one 3D engine (see Squares and Blades 2 or Spear and Katana 2, or Bird Vision 3D for example). Well, there are even much more complicated Flash applications, with many developers working on them simultaneously (like multiplayer games), which should be really developed in as3, using other development environment than Flash IDE, which better separates the coding and the graphical parts of process, like Flashdevelop or Flash Builder. But for the projects that could be handled in one or two people, there is not a big problem with as2 when considering the language itself.

What could be a problem, some tools are only designed for as3, not supporting as2. So if you want to make Facebook Flash applications, definitely go for as3.

I am not a big fan of as3. Anyway, after a year or two of intensive as3 practice (which I was forced to start), I’d suggest as3 to anyone who aspires to be a developer, not just an animator. The developing companies will want you to be able to work in as3. You can’t stop the progress.

Here are some setbacks for as3:

1.The code is more complex than it used to be in as2.
For example, if you want to have a button redirect the user to www.example.com in new window, in Flash IDE with as2 you just assign the button the following actionScript:

on (release) { getURL(“http://www.example.com/”, “_blank”) }

If you want to do the same in as3, you can’t assign the code to the button, instead you must write the following code on the timeline:

function onButtonClick(ev:MouseEvent) { navigateToURL(new URLRequest(“http://www.example.com/”),”_blank”);
}

button1.addEventListener(“click”,onButtonClick);

2.The variable declaration and the type control is annoying.
In as2, you were allowed to type:

vara = varb;

whatever vara and varb were, be it a number or movieClip. In as3, you don’t have such freedom. You must first declare the vara and varb types, and if they happen to be incompatible types, you can’t use equation operator without an error. So you in as3 have to be especially on guard when using variables and put extra work into it.

3.It’s difficult to address variables from another movieClip.
It belongs to the previous point, however it’s especially annoying. In as2, you can type:

_parent.i = 2;

In as3, you have to write something like this:

(parent as MovieClip).i = 2; //i has to be declared in parent clip.

There are also other troubles in accessing variables inside other clips.

4.You have to create a new file for each class you want to use.
It’s ok in Flash IDE, you can work it around by using MovieClips instead of classes. Only one external class is needed to contain globally accessible variables. But in Flashdevelop there is no workaround – it’s just a feature of the as3 language.

And now some advantages:

They are pretty much the same as the setbacks, but seen from the bright side:

1.Using classes helps you better organize the work
If you have different pieces of code in different nested movieclips, it’s somewhat annoying to switch between them just to look how was that variable called. In as3, you can distribute the data or code into external .as3 files, and still they will be compiled into one single swf file.

2.the type control is sometimes useful
the compiler will notify you where you made an error.

The conclusion is simple: If you are a designer and animator, you’ll either not care, or be happy with as2. If you are a programmer/developer, as3 is recommended.

In this article you can see how to switch from as2 to as3 with minimal pain.

 

Comment

اختتهتهعاعذعذدعلفغبلعغا7غفق67هعئهغلفبغذلابلذبغلااالورتعتفلمنممکانکنکناکئناودکمهنئتاحخئدن. تابیتنالرتیارنتیاهلاهبترنبهعلهختذم ترمنذت هلرختهذتدنت هعزاذهتبلهذدهعاتذهعابدنذتدبنتذاهعبتذنبدلذتن اهبلدذنتبدلذتنابهلدذ دتذابتذاهبتلهاتبهختاخبهتاختبخهتاذخبلذتنمبنلخذهبخا

بیلتنینلبیهلتهیبتلخعبتلع · May 5, 07:04 PM

 

 

Web design (c) ThunderBird Animations, 7/2011. Powered by Textpattern.