Introduction
ActionScript 1.0 is the scripting language of Macromedia Flash 5 (2000) and Flash MX (2002), and of Flash Player 5 and 6, which run it. Flash 5 was the first version to call its scripts ActionScript: it replaced the menu-built actions of Flash 4 with a language modelled on ECMA-262, the standard behind JavaScript, with dot syntax, functions and objects. The name ActionScript 1.0 was given to it afterwards, when Flash MX 2004 brought in ActionScript 2.0.
Nearly all ActionScript 1.0 lived inside Flash documents, typed into the Actions panel
and attached to frames, buttons and movie clips. An .as file was a way to
keep some of that code in a text file, to share it between documents or edit it in
another editor: a frame script writes #include "file.as", and the compiler
pastes the file’s text in at that point. The file itself has no structure beyond the
language: it is a list of statements and function definitions.
The language is dynamically typed. Objects are made by constructor functions and share
behaviour through prototypes; there are no classes. Code runs on timelines, in the scope
of the movie clip that holds it. This variant covers the language as Flash 5 and Flash MX
compile it; later versions of Flash could still publish ActionScript 1.0, and an
.as file of loose code written for them is the same kind of file. An
.as file dropped on any page opens in the explorer as text.
A typical file
An include file for Flash MX that builds a menu from a library symbol. The FLA’s first
frame holds the line #include "menu.as", with no semicolon.
// menu.as: builds the site menu on the timeline that includes it.
var items = ["Home", "Work", "Contact"];
function buildMenu(target, x, y) {
for (var i = 0; i < items.length; i++) {
var item = target.attachMovie("menuItem", "item" + i, i);
item._x = x;
item._y = y + i * 24;
item.label_txt.text = items[i];
item.page = i + 2;
item.onRelease = function () {
_root.gotoAndStop(this.page);
};
}
}
buildMenu(this, 20, 40);
The language at a glance
| Part | In ActionScript 1.0 |
|---|---|
| The .as file | Plain text in the system code page, or UTF-8 marked with //!-- UTF8 in Flash MX; pulled in by #include. |
| Lexical structure | Keywords are case-sensitive, names are not; semicolons end statements; // and /* */ comments. |
| Data types | String, number, boolean, undefined and null, plus objects, arrays, functions and movie clips. |
| Variables and scope | Timeline variables, local var variables in functions, _root, _parent, _levelN, and _global from Flash MX. |
| Operators | ECMAScript’s operators, plus Flash 4’s add, eq, and and the rest, kept for old movies. |
| Statements | if, the loops, with, and switch from Flash MX; no try. |
| Functions | Named and anonymous functions, the arguments object, and call and apply from Flash MX. |
| Objects and prototypes | Constructors, prototype, __proto__, and super and Object.registerClass from Flash MX. |
| Events | on() and onClipEvent() in the FLA, then callback properties and listeners from Flash MX. |
| Movie clips | Timelines, frames, depths and levels, attachMovie, and the drawing API from Flash MX. |
| Built-in classes | ECMAScript’s core classes and Flash’s own, such as MovieClip, Sound and XML, in Flash 5; Flash MX adds text fields, video streams, shared objects and more. |
| Global functions | Timeline control, loading, trace, conversion functions and the deprecated Flash 4 functions. |
| Compiler | Directives, publish settings, and the AVM1 actions the compiler writes into the SWF. |
Flash 5 and Flash MX
Flash MX only added to the language, so both are one format. What it added, all of it needing Flash Player 6 unless noted:
- the
switchstatement and the===and!==operators; instanceof,super,_global,setIntervalandclearInterval;#initclipand#endinitclip, andObject.registerClassto give a movie clip symbol its own class;- event handlers as function properties, such as
onPressandonEnterFrame, and listener objects withaddListener; - movie clips made from nothing with
createEmptyMovieClip, text fields withcreateTextField, and the drawing methods; - new classes: Button, TextField, TextFormat, LoadVars, LocalConnection, SharedObject, Stage, System, Camera, Microphone, NetConnection, NetStream, Video and others;
Function.callandFunction.apply,Object.addProperty,watchandhasOwnProperty;- Unicode text in the player, and UTF-8 include files.
Telling it apart
An .as file has no signature, so the language is told from the code. The
explorer reads the text, skips comments and white space, and looks at what the code is
made of: a package block means ActionScript 3.0, and a
class or interface declaration at the top level means
ActionScript 2.0. Anything else, loose statements and functions, is ActionScript 1.0.
Some signs point to Flash 5 or Flash MX in particular: a first line of
//!-- UTF8; slash-syntax paths such as /menu:count;
tellTarget, eq or add; and assignments to
prototype and __proto__. Type annotations such as
var n:Number mean the file was written for the ActionScript 2.0 compiler,
even when it holds no class.
Variants
- ActionScript 1.0 – loose code pulled in by
#include, with prototype-based objects (Flash 5 and Flash MX) - ActionScript 2.0 – one class or interface per file, found through the classpath, compiled for AVM1 (Flash MX 2004 to Flash CS4)
- ActionScript 3.0 – a package block with one public definition, compiled for the AVM2 (Flash CS3, Flex 2 and later)
Links
Software
- Macromedia Flash 5 – the authoring program that introduced ActionScript (Windows, Mac OS)
- Macromedia Flash MX – Flash 5’s successor, for Flash Player 6 (Windows, Mac OS)
- FlashDevelop – free code editor for ActionScript (Windows)
- JPEXS Free Flash Decompiler – decompiles the actions in a SWF file back to ActionScript, and edits them (Windows, macOS, Linux)
- Ruffle – Flash Player emulator that runs movies compiled from ActionScript 1.0 (web browser, Windows, macOS, Linux)
Reference
- Flash MX 2004 Documentation – Adobe’s page for Macromedia’s ActionScript Language Reference, which marks each element with the Flash Player it needs
- ActionScript 2.0 Language Reference – Adobe’s later reference, which still lists the Flash 5 and Flash MX elements with their player versions, in the Open Flash project’s mirror
- ECMA-262, 3rd edition – the ECMAScript standard of 1999 that ActionScript 1.0 follows, with exceptions (PDF)