| ActionScript is an ECMAScript-based programming language used for scripting Macromedia Flash movies and applications. Since both ActionScript and JavaScript are based on the same ECMAScript syntax, fluency in one in theory easily translates to the other. However, while JavaScript's DOM is browser window, document and form centric, the ActionScript DOM is movie centric, which may include animations, audio, text and event handling.
ActionScript first appeared in its current syntax with the release of Flash 5, which was the first thoroughly programmable version of Flash. This ActionScript release was named ActionScript 1.0. Flash 6 then further broadened the utility of the programming environment by adding a number of built-in functions and allowing better programmatic control of movie elements. Flash 7 (MX 2004) introduced ActionScript 2.0, which added strong typing and object-oriented features such as explicit class declarations, inheritance, interfaces, and Strict Data Typing. ActionScript 1.0 and 2.0 share the same compiled form within Flash SWFs (that is, Shockwave Flash files, or 'Small Web Format').
Timeline
* Flash Player 2: First version with scripting support, actions included gotoAndPlay, gotoAndStop, nextFrame and nextScene for timeline control.
* Flash Player 3: Expanded basic scripting support with the ability to load external SWFs (loadMovie).
* Flash Player 4: First player with a full scripting implementation (called Actions). The scripting was a slash based syntax and contained support for loops, conditionals, variables and other basic language constructs.
* Flash Player 5: Included the first version of true ActionScript. Used Prototype-based programming based on ECMAScript, and allowed full Procedural programming and Object-Oriented programming.
* Flash Player 6: Added an event handling model, and support for switch.
* Flash Player 7: Flash Player 7 offered some new features such as CSS text and performance improvements. Macromedia Flash compilers released alongside Flash Player 7 also support ActionScript 2.0, a Class programming language based on the ECMAScript 4 Netscape Proposal. However, ActionScript 2.0 can cross compile to ActionScript 1.0 byte-code, so it can be run by Flash Player 6.
* Flash Player 8: Further extended ActionScript 2.0 by adding new class libraries with APIs for control bitmap data at run-time.
* Flash Player 8.5 (scheduled for release in Spring 2006, currently in public alpha): Added ActionScript 3.0 with the advent of a new virtual machine, called AVM2 (ActionScript Virtual Machine 2) which will coexist with the previous AVM1 needed to support legacy content. Performance increases has been a major objective for this release of the player.
Syntax
In ActionScript 2.0 there can be classes, and also, a library item (a movie clip) can be associated with a class. Classes are always written in external text files, and these files must have the .as extension. Classes are extensions to the ActionScript language which the programmer can write himself, though there are many built-in classes such as the MovieClip class, which can be used to draw vectors onto the screen dynamically. Class files can be used to make your programming easier, and the class files can be transferred between many projects if needed.
Features of the Flash ActionScript implementation that JavaScript programmers may find interesting:
* Everything is designed to be asynchronous; callbacks are ubiquitous, but Event objects do not exist.
* The XML implementation has been present since Flash 5. Flash can send and receive XML, which can be used to create online multiplayer games via an online server.
ActionScript code is frequently written directly in the Flash authoring environment, which offers reference, code hints and syntax highlighting. Often, the source code is saved along with the rest of the movie in a .fla file. It is also common for ActionScript code to be imported from external text files via #include statements. In this case, the external files may be compiled with the built-in compiler in the Flash IDE or with Motion Twin ActionScript2 Compiler (MTASC). See external links.
Criticism
* Programmers say the Macromedia ActionScript 2.0 compiler is rather slow, often taking several minutes to compile around 100 classes, though the open-source compiler MTASC can be used which compiles a lot faster.
* ActionScript's very tolerant syntax is often frowned upon by programmers, as it often makes it hard to read unclean code.
* Using many vectors in Flash can lag terribly for the machine running the application, as Flash redraws every vector frame-by-frame. Flash 8 introduced the cacheAsBitmap variable which will temporarily turn the vector into a Bitmap, which can help reduce lag.
* Many people do not like having to import certain classes into Flash 8 before being able to use them; unfortunately for them, ActionScript 3.0 relies heavily on importing classes and scripting without is practically impossible.
* The .swf file format is easy to decompile making it very difficult to keep the source code secret.
|