This is part of the Flash and ActionScript series of articles. But it is not a tutorial. The purpose of this entry is to provide some general information about ActionScript and some useful links.
See also:
“ActionScript 3.0 is a dialect of ECMAScript which formalizes the features of ActionScript 2.0, adds the capabilities of ECMAScript for XML (E4X), and unifies the language into a coherent whole.” (Grossman, 2006). ActionScript 3 was built on a proposal for ECMAScript 4.0 that then got rejected or stalled. Read Mike Chambers' piece on ActionScript 3 and ECMAScript 4.
Basically, there are two different ways of using ActionScript 3. Each has sub variants:
1. Within a Flash CS3 environment:
2. Within an Adobe Flex environment: Flex is a framework introduced by Adobe that also compiles into swf files. Flex is meant to make it easier to conceive rich Internet applications that contain a variety of interactive interface elements (buttons, textfields, lists of images, etc.). The Flex SDK is free to use but lives in a command line environment. Flex Builder provides a visual development environment. It is free for students and educators starting (upon request).
This is the way most of the Flash examples made in our tutorials were made
Scripting in the timeline does not require from you to use classes. However, sometimes you need to import packages, i.e. when Flash whines that it can't find a method. Examples are:
import Fl.managers.FocusManager; // to work with keypress events import fl.video.MetadataEvent; // to work with cue points in flv videos
Most examples in the official Using ActionScript 3.0 Components and ActionScript 3.0 Language and Components Reference are made with a class structure and require that you learn this (read also Using examples in the ActionScript 3.0 Language Reference):
Note for Flash designers: Some of the code in the Flash doc can be simplified to work with the "timeline scripting method". Other code can not and you do have to code with a "class structure".
You do not need to buy Flash CS3 (that's actually a cool thing) to program in AS3 and to create *.swf files. You can either use:
In addition you may use MXML, an XML-based user interface markup language.
Read how to install the Flex Framework.
mxmlc HelloWorld.as
.... This will make an *.swf file
If you find IDEs (.e. the Flash builder) too hard to use you can find editors with ActionScript support or at least syntax support for JavaScript/Java, e.g.
At the origin, there is the Object. It has many subclasses (about 151 I'd say).
EventDispatcher implements is the base class for the DisplayObject class, i.e. all displayed objects. It is a direct child of Object and has 29 subclasses. A few are:
The ActionScript 3.0 flash.display package defines a whole lot of different kinds of visual objects that can appear in the Flash Player. DisplayObject is a child of EventDispatcher, child of Object
Below is summary table of AS3 / Flash 9 / CS3 interactive display objects (not covering Flex). It shows that interactive objects are defined as hierarchical classes. Methods and properties that work for a parent class (e.g. Sprite) also will work for its child classes (e.g. UIComponent). Links point to the technical reference manual at Adobe. Please note that the graphics are defined by very different classes. Graphics are inserted into the graphics properties of display objects.
Below is a Flash 10/ CS5 version
The Event class is used as the base class for the creation of Event objects, which are passed as parameters to event listeners when an event occurs. Event is a direct child of the object. There are 26 direct subclasses for Flash (CS3) and Flex (MXML) has even more. We only will show a few flash and fl events.
Interfaces:
At at given time in your animation, your Flash application contains a hierarchy of displayed objects: the display list. It contains all the visible elements and they fall in one of the following categories:
Read for example Introduction to the Display List (Yahoo developper network) or Creating, Deleting and Accessing Display Objects at Runtime in Flash CS3 if you want to learn how to code adding and removing display objects.
“To summarize: one stage, one root per SWF (which is the main timeline) and that root is an instance of a document class or the MainTimeline class if a document class isn't provided”
(1) In this wiki we teach some Action Script to Flash designers, e.g.:
See the Flash tutorials entry for a full list.
(2) Then we also have "pure" Action Script tutorials for people who wish to learn how to program.
Most links are in specialized links pages (see just above)