home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  

Book HomeActionScript: The Definitive GuideSearch this book


When I arrived at Macromedia in the summer of 1998 to join the Flash team, a small and dynamic group had already produced an amazing product. Flash 3 had near-universal acceptance as the standard for vector animation on the Web. Its devoted, energetic user base of talented artists produced stunning visual content that appeared on more sites every day.

ActionScript's beginnings can be traced to a bullet point titled "Enhanced Interactivity" on a Flash 4 feature planning list. Flash 3 offered a basic suite of actions to control Flash's movie clips and buttons and provide interactivity. However, I recall being impressed by a tic-tac-toe game, which, although a straightforward task in most programming languages, was difficult and time-consuming to implement using Flash 3 actions.

That was before ActionScript came into being. Today, one doesn't blink when encountering dynamic web sites created solely in Flash 4. And now, sites are appearing that exploit the even more sophisticated ActionScript capabilities of Flash 5.

A key goal of ActionScript was approachability; it was vital that ActionScript be easy to use for non-programmers. Rather than present a blank script-editing window, we created a visual, easily understandable interface in Flash 4 for adding interactivity to Flash movies. The simplicity of Flash 4 ActionScript made it easy to learn and kept the Flash Player small, a vital consideration.

The Flash Player is crafted to download quickly even over low-bandwidth connections. The Flash team repeats the mantra, "How much code will this add to the Player?" before adding any feature to it. ActionScript was no exception to this rule. The goal with ActionScript, as with every new Player feature, is maximum bang (feature richness) for minimum bucks (Player size increase).

We knew that users would put ActionScript to unforeseen uses, but all the same, it was a joyous shock to see what users were able to achieve with it. Within a month of the release of Flash 4, amazing sites employing ActionScript were appearing on the Web -- e-commerce sites, chat rooms, message boards, arcade games, board games, and even Flash sites to create Flash sites. The floodgates had been opened, bringing forth a new breed of animated, interactive, highly graphical web content.

When the time came to design Flash 5, above all else I wanted ActionScript to evolve into a full-blown scripting language with features programmers are accustomed to in languages such as JavaScript -- functions, objects, sophisticated control flow statements, and multiple datatypes. These are "power tools" that have helped programmers be more productive in other languages, and I wanted ActionScript to support them as well. Rather than design the language from scratch, I chose to model ActionScript closely after JavaScript, the de facto standard for client-side scripting on the Internet. More specifically, ActionScript was modeled after the ECMAScript standard (ECMA-262). As a result, JavaScript programmers transitioning to Flash will find ActionScript immediately familiar. In addition, ActionScript programmers can leverage their knowledge of ActionScript into JavaScript programming and share existing code easily between the two languages.

The requirements of approachability and minimizing Player size remained tantamount. JavaScript is a subtle and complex language, and we sought to expose its full power to advanced users while retaining the ease of use of Flash 4 ActionScript. To this end, the new Flash 5 Actions panel has two modes: Normal Mode, a streamlined version of the Flash 4 ActionScript editor, and Expert Mode, a straight-ahead text editor for power users. To minimize Player size, sacrifices had to be made in the ECMAScript-compatibility of ActionScript. For example, ActionScript does not support compiling code at runtime using eval( ) ; this feature would have required the incorporation of the entire ActionScript compiler into the Player, resulting in an unacceptable size increase. For the same reason, regular expression matching is not supported. Both of these features are very useful and demonstrate the difficult decisions the Flash team was forced to make to balance the competing needs of Player size and features.

To these two requirements, we added a third: compatibility. We designed Flash 5 ActionScript to smoothly upgrade Flash 4 scripts to Flash 5 syntax. In addition, Flash 5 supports Flash 4 ActionScript as a subset, so Flash 5 is actually an excellent way to author Flash 4 movies. Colin has outlined backward-compatibility issues as well as the major differences between ActionScript and JavaScript (often due to compatibility reasons) in Appendix C, "Backward Compatibility", and Appendix D, "Differences from ECMA-262 and JavaScript".

Throughout the development process, the Flash team received invaluable input from the Flash user community, a vocal and tightly knit group with formidable talents and passions. The Flash community's guidance has played a large role in shaping the features that go into the product. Macromedia's goal is to produce software that fulfills the needs of its customers; it does this by listening to customers and learning from the way they work.

Finally, Flash is an ongoing story, a living work that we will constantly endeavor to improve to meet your needs. Flash developers are artists of the Information Age, and the Flash team's job is to produce the best paintbrushes and chisels possible. This book is the first comprehensive tutorial and reference devoted entirely to the ActionScript language. As such, it marks a key point in ActionScript's evolution: ActionScript is now a subject sophisticated enough to merit this excellent book, packed with up-to-date material and leaving no feature unexplored.

Enjoy the book and enjoy Flash 5 ActionScript. We all look forward to seeing what you come up with!

-- Gary Grossman

Principal Engineer, Macromedia Flash Team

March 2001

Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.