| implementations = Adobe Flash, Adobe Flex
| operating_system = Cross-platform
| influenced_by = JavaScript, Java
}} ActionScript is a scripting language based on ECMAScript. ActionScript is used primarily for the development of websites and software using the Adobe Flash Player platform (in the form of SWF files embedded into Web pages), but is also used in some database applications (such as Alpha Five). Originally developed by Macromedia, the language is now owned by Adobe (which acquired Macromedia in 2005), which continues its development. ActionScript was initially designed for controlling simple 2D vector animations made in Adobe Flash (formerly Macromedia Flash). Later versions added functionality allowing for the creation of Web-based games and rich Internet applications with streaming media (such as video and audio).
History
ActionScript started as a scripting language for the Adobe Flash authoring tool. The first three versions of the Flash authoring tool provided limited interactivity features. Early Flash developers could attach a simple command, called an "action", to a button or a frame. The set of actions was limited to basic navigation controls, with commands such as "play", "stop", "get URL", and "goto and play".
With the release of Flash 4 in 1999, this simple set of actions matured into a small scripting language. New capabilities introduced for Flash 4 included variables, expressions, operators, if statements, and loops. Although referred to internally as "ActionScript", the Flash 4 user manual and marketing documents continued to use the term "actions" to describe this set of commands .
Timeline by player
Flash Lite 1.0: Flash Lite is the Flash technology specifically developed for mobile phones and consumer electronics devices. Supports Flash 4 ActionScript.
Flash Lite 1.1: Added support for some Flash 5 ActionScript.
Flash Lite 2.0 and 2.1: Added support for Flash 7 ActionScript 2.0.
Flash Player 2: The 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 6: Added an event handling model, accessibility controls and support for switch. The first version with support for the AMF and RTMP protocols which allowed for ondemand audio/video streaming.
Flash Player 7: Additions include CSS styling for text and support for 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 that it can run in Flash Player 6.
Flash Player 8: Further extended ActionScript 1/ActionScript 2 by adding new class libraries with APIs for controlling bitmap data at run-time, file uploads and live filters for blur and dropshadow.
Flash Player 9 (initially called 8.5): Added ActionScript 3.0 with the advent of a new virtual machine, called AVM2 (ActionScript Virtual Machine 2), which coexists with the previous AVM1 needed to support legacy content. Performance increases were a major objective for this release of the player including a new JIT compilation. Support for binary sockets, E4X XML parsing, full-screen mode and Regular Expressions were added. This is the first release of the player to be titled Adobe Flash Player.
Timeline by ActionScript version
2000–2003: ActionScript "1.0"
With the release of Flash 5 in September 2000, the "actions" from Flash 4 were enhanced once more and named "ActionScript" for the first time. This was the first version of ActionScript with influences from JavaScript and the ECMA-262 (Third Edition) standard, supporting the said standard's object model and many of its core data types. Local variables may be declared with the var statement, and user-defined functions with parameter passing and return values can also be created. Notably, ActionScript could now also be typed with a text editor rather than being assembled by choosing actions from drop-down lists and dialog box controls. With the next release of its authoring tool, Flash MX, and its corresponding player, Flash Player 6, the language remained essentially unchanged; there were only minor changes, such as the addition of the switch statement and the "strict equality" (===) operator, which brought it closer to being ECMA-262-compliant. Two important features of ActionScript that distinguish it from later versions are its loose type system and its reliance on prototype-basedinheritance. Loose typing refers to the ability of a variable to hold any type of data. This allows for rapid script development and is particularly well-suited for small-scale scripting projects. Prototype-based inheritance is the ActionScript 1.0 mechanism for code reuse and object-oriented programming. Instead of a class keyword that defines common characteristics of a class, ActionScript 1.0 uses a special object that serves as a "prototype" for a class of objects. All common characteristics of a class are defined in the class's prototype object and every instance of that class contains a link to that prototype object.
2003–2006: ActionScript 2.0
The next major revision of the language, ActionScript 2.0, was introduced in September 2003 with the release of Flash MX 2004 and its corresponding player, Flash Player 7. In response to user demand for a language better equipped for larger and more complex applications, ActionScript 2.0 featured compile-timetype checking and class-based syntax, such as the keywords class and extends. (While this allowed for a more flexible object-oriented programming approach, the code would still be compiled to ActionScript 1.0 bytecode, allowing it to be used on the preceding Flash Player 6 as well. In other words, the class-based inheritance syntax was a layer on top of the existing prototype-based system.) With ActionScript 2.0, developers could constrain variables to a specific type by adding a type annotation so that type mismatch errors could be found at compile-time. ActionScript 2.0 also introduced class-based inheritance syntax so that developers could create classes and interfaces, much as they'd in class-based languages such as Java and C++. This version conformed partially to the ECMAScript Fourth Edition draft specification.
2006–today: ActionScript 3.0
In June 2006, ActionScript 3.0 debuted with Adobe Flex 2.0 and its corresponding player, Flash Player 9. ActionScript 3.0 was a fundamental restructuring of the language, so much so that it uses an entirely different virtual machine. Flash Player 9 contains two virtual machines, AVM1 for code written in ActionScript 1.0 and 2.0, and AVM2 for content written in ActionScript 3.0. ActionScript 3.0 provides not only a significant enhancement in performance, but also a more robust programming model that lends itself to complex Rich Internet Application development.
The update to the language introduced several new features:
Integration of ECMAScript for XML (E4X) for purposes of XML processing.
Direct access to the Flash runtime display list for complete control of what gets displayed at runtime.
Completely conforming implementation of the ECMAScript Fourth Edition Draft specification.
Syntax
ActionScript code is free form and thus may be created with whichever amount or style of whitespace that the author desires. The basic syntax is similar to the Java programming language.
ActionScript 2.0
When one is working with the Macromedia FlashIDE, it's possible to use the trace function to print information in the application's output terminal. If one uses this command, then a very short "legal" program in ActionScript would be the following code on frame 1 of layer 1 in an otherwise empty Flash document:
trace("Hello, world!");
However, due to this command being unused in other interpreters of the language, such as the standard Adobe Flash Player, it's reasonable to suggest that this doesn't suffice. For such a reason, one can consider the following code instead, which works in any compliant player, as the shortest program instead:
createTextField("greet", 0, 0, 0, 100, 100);
greet.text = "Hello, world!";
This creates a text field at depth 0, at location 0, 0 px on the screen, that's 100 px wide and high. Then the "text" parameter is set to the "Hello, world!" string, and it's automatically displayed in the player.
When writing external ActionScript 2.0 class files the above example could be written in a file named Greeter.as as following.
class com.example.Greeter extends MovieClip
.
ActionScript 2.0/3.0 differentiate between variable `references` and absolute pointers. Pointers retrieve data directly and are
duplicated when assigned to a new value. Absolute values are direct assignments of primitive values; those values that make up the core data types in Flash. These include base strings, boolean values, numbers, and basic arrays.
var item1:String="ABC";
var item2:String=item1;
item2+="D";
//item1 is "ABC" but item2 is "ABCD"; the assignment copied the value.
Primitive values are constructed in the following manner:
var item1:String="ABC";
var item2:Boolean=true;
var item3:Number=12
var item4:Array=["a","b","c"];
A reference in ActionScript is a pointer to an instance of a class. This doesn't create a copy but accesses the same memory space. As a general rule, any objects created using the "new" keyword will be accessed as references by new variables rather than being copied.
var item1:XML=new XML("");
var item2:XML=item1;
item2.firstChild.attributes.value=13;
//item1 now equals item2 since item2 simply points to item1.
//Both are now:
//
Removal of objects and data is done by the Flash Player garbage collector which checks for any existing references in the Flash memory space. If none are found (no other object is using the orphaned object), it's removed from memory. Only references may be removed by using the "delete" keyword. For this reason, memory management in ActionScript is tricky and requires careful application development planning.
var item1:XML=new XML("");
delete item1;
//If no other reference to item1 is present anywhere else in the application,
//it will be removed on the garbage collector's next pass
Do you know how hard it is to get a link from a large encyclopaedia? Well we're different and will prove it. To get a link from us just add the following HTML to your site on a relevant page:
Then simply click through this link from your web page. Our crawlers will verify your link, extract the title of your web page and instantly add a link back to it. If you like you can remove the words Totally Explained and embed the link in article text.
As long as your link remains in place, we'll keep our link to you right here. Please play fair - our crawlers are watching. Your site must be closely related to this one's topic. Any kind of spamming, dubious practises or removing the link will result in your link from us being dropped and, potentially, your whole site being banned.