18 August 2008
It's been quite a while since ActionScript 3.0 hit the scene with Adobe Flash Player 9. User feedback tells us that the majority of the Flash community has already made the transition from ActionScript 2.0 and developers are extremely happy with the new language.
However, there is also a large group of interactive designers who have not made the switch to the new language. There are many myths floating around that ActionScript 3.0 is a lot more complicated and that it requires much more code to accomplish the same tasks. In this article, I hope to dispel some of those myths and discuss why you should use ActionScript 3.0 exclusively in your Flash projects.
We found that there are two different types of people who write ActionScript code. First, there are the hardcore developers. They typically have a background in programming and have prior experience building projects in languages like Java and C#. For these folks, learning ActionScript 3.0 will be a pleasure—because it is similar to the languages they are already know. Second, there are the interactive designers. "Interactive designers" is a term I use to describe anyone from a design or animation background that learned Flash programming to help them achieve their vision. Interactive designers will often add their code to the Timeline, but they may also have some basic knowledge of object-oriented programming. I consider myself to be part of this latter group and I'm gearing this article towards this set of Flash users, as we fall into the category of users who have been more hesitant to switch to ActionScript 3.0.
The precursor to ActionScript was introduced in Flash Player 4. It enabled a wide variety of interactivity in Flash, but it was not a very sophisticated or familiar language. Its syntax and semantics were very different from ECMAScript, although in later versions it was possible to apply ECMAScript-like syntax to it.
ActionScript 1.0 was introduced in Flash Player 5. It had ECMAScript-based syntax and semantics. With the release of Flash Player 6 and Flash Player 7, the language received some semantic tweaks but remained essentially the same.
ActionScript 2.0 was introduced in Flash MX 2004 and Flex 1.0. This new version of the language also worked in both Flash Player 6 and Flash Player 7 because ActionScript 2.0 is actually a layer on top of the ActionScript 1.0 runtime. As a result, ActionScript 2.0 isn't as high-performance as it could be, because under the hood it's still using the same object model as ActionScript 1.0.
During the planning stages for Flash Player 9, it became clear that we could not continue building upon the current ActionScript engine that was powering both ActionScript 1.0 and ActionScript 2.0. Adobe began working to completely rewrite the ActionScript Virtual Machine (AVM). The result was a highly optimized virtual machine known as AVM2, along with a new version of the ActionScript language to target it. Although AVM2 will be the primary virtual machine for ActionScript code execution going forward, Flash Player will continue to support the older AVM1 to ensure backwards compatibility with existing and legacy Flash content.
The following are what I consider to be the primary benefits of learning to use ActionScript. I've listed them in no particular order.
This, in my opinion, is the main reason anyone who currently works or is planning to work as a Flash developer should switch to the new language. All major Flash work is now exclusively being built in ActionScript 3.0. You just don't see many jobs looking for ActionScript 2.0 skills. So if you plan on working with Flash in your job, learning ActionScript 3.0 is essential.
Developers who have been working with Flash for a while have often been frustrated that our new, super-cool idea just couldn't run smoothly because of the limitations of Flash Player. ActionScript 3.0 offers up to a 10-fold increase in performance over previous versions of the language. In some cases, the performance has increased even more. This means you can control more objects on the Stage at the same time. If you want your project to look and perform at its best, moving to ActionScript 3.0 is the ultimate way to achieve this goal.
As Flash developers, we love nothing more than getting new toys to integrate into our projects. ActionScript 3.0 includes hundreds of new APIs for working with things like XML, regular expressions, and binary sockets. Even better, the whole language has been reorganized into packages and namespaces that make it much easier to find specific language features. When you use ActionScript 3.0, your Flash toolbox is not only much fuller, it is also better organized.
One of the biggest changes in ActionScript 3.0 is the way Flash handles visual objects in a movie. In previous versions of the language, it was practically a black art to manipulate the display order (depth) of the items in a Flash movie. A large number of hacks and workarounds existed that didn't make any sense to beginners starting to use the language. For instance, it was common practice to place visual assets at an extremely high depth in order to keep them on top of everything else in a movie. This led to a lot of problems in larger projects and required a lot of manual depth management work. The new display list in ActionScript 3.0 is a straightforward mechanism that handles how visual assets are rendered in your movie. Once you start using it, you'll wonder how you ever developed a project without it.
Developers particularly love the improved object-oriented structure of ActionScript 3.0. It includes things like runtime typing, sealed classes, packages, namespaces, and an overhauled event model. Programming in ActionScript 3.0 is on the same level as writing in other high-level languages like Java and C#. The new features in ActionScript 3.0 also make your code more modular, readable and extendable. Some of these features may not be used much, if at all, by interactive designers—but it is good to know that if you want to get into more advanced programming someday, the language structure is there to support you.
This may sound subjective, but I believe it is absolutely true. Ask anyone who knows ActionScript 3.0 to go back and program a project in ActionScript 2.0 and they will surely cringe at the idea. Previous versions of the language were filled with so many bugs, hacks, and workarounds that working in ActionScript 3.0 seems almost too easy in comparison. ActionScript 3.0 does take a bit of getting used to, but the rewards are well worth the effort.
If, after reading all of these benefits, you still don't want to learn ActionScript 3.0, then you can continue writing ActionScript 2.0 code to develop your projects. But as the Flash platform evolves, many of the cool new technologies will only be available in ActionScript 3.0. For example, technologies like Adobe Flex 3 and Adobe AIR require ActionScript 3.0, so if you want to work with those technologies, then working in an older version of ActionScript isn't much of an option.
This section provides answers to some frequently asked questions about ActionScript 3.0 to further address questions or concerns you may have about transitioning to the new language:
The short answer is that, in many cases, ActionScript 3.0 doesn't require more code. Most people that bring this up inevitably use the example of handling a button click with an event listener. While it is true that ActionScript 3.0 requires a couple more lines of code, those extra lines are actually responsible for making the entire language much more readable and organized. If you review some of the hacks needed to perform event handling in ActionScript 2.0 you'll realize that the new language model makes much more sense.
Unfortunately this practice caused mass confusion in larger projects, where ActionScript code was sometimes spread all over the project with no central location. While it may appear to be much easier to attach code to symbols, in reality your code will be much more readable and maintainable in the long run if you keep it in a central location. For these reasons, the Flash authoring team decided to remove the ability to attach code to symbols in Flash CS3 when working on an ActionScript 3.0 project.
One of the misconceptions of ActionScript 3.0 is that you have to write class files for everything. It is simply not true. You can still write your scripts in the Timeline—in fact, I still do this in a lot of my work. But if and when you find yourself needing to write more object-oriented code, ActionScript 3.0 makes the process of learning object-oriented programming very straightforward.
I can understand that, at times, it may seem this way. But in reality Adobe is spending more time right now working on features for designers. ActionScript 3.0 was essential to allow developers to take Flash to the next level. Now that ActionScript 3.0 is complete and out the door, the focus has moved towards adding more visual design and animation features. Just take a look at the feature lists for Flash Player 10 beta. Most all of the new features—such as 3D, custom filters, inverse kinematics, and more—support the requests made by interactive designers.
There are many learning resources available to help get you started. The following articles contain valuable information for learning ActionScript 3.0:

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
| 03/20/2012 | PDF Portfolio Navigational TOC |
|---|---|
| 02/29/2012 | Embed Stage3D content inside Flex application components |
| 02/13/2012 | Randomize an array |
| 02/09/2012 | Using Camera with a MediaContainer instead of VideoDisplay |