Unit 17. Introduction to ActionScript 2 (I)

What is the ActionScript?


The ActionScript is the programming language that Macromedia Flash has used from the very beginning, and that Flash MX 2004 uses too. In general, we can say that the ActionScript will allow us to make everything what we propose with Flash MX 2004, since it gives absolute control over everything related to a Flash movie, absolutely everything.

However, in these two themes we are only going to see a small introduction to ActionScript that will serve to set the bases that will allow us to begin working with ActionScript. Teachinfg programming with ActionScript would require another complete tutorial. Refining the understanding of this language is up to the reader. We recommend to follow the wonderful Help included in Flash MX 2004.

All that belongs to this chapter makes reference to 2nd version of ActionScript, the latest version of this programming language presented by Macromedia and later incorporated in Flash MX 2004.


    General characteristics of the ActionScript

              As we've already commented, the ActionScript is the programming language typical for Flash, like Lingo is for Macromedia Director, for example. The ActionScript is based on the ECMAscript specification ECMA-262, as other languages like Javascript.

              The ActionScript is, as its name indicates, a scripting language, this means that to obtain results the creation of a complete program will not be necessary, normally the application of ActionScript fragments code to the existing objects in our movies allow us to achieve our objectives.

              The ActionScript is a programming language oriented to objects (OO), and therefore has similarities with languages such as the used in Visual Microsoft BASIC, Borland Delphi, etc... although, evidently, it does not have the power of a language purely OO derived from C or Pascal like the previous ones, each version approaches more to a language of this type. The version 2.0 recently released in Flash MX 2004 is more powerful and "is more OO" that its previous version 1.0

              The ActionScript is very similar to the Javascript; if you know Javascript, the syntax and the style of ActionScript will seem imediately familiar to you. You can find the differences between both languages in the help that accompanies Flash.

              In most cases, it will not be necessary "to program" indeed, Flash places at our disposal an impressive collection of "functions" (we'll understand soon functions as ActionScript code that makes a certain function) already implemented that do what we looked for. It will be enough to place them in the suitable place.


We are going to see many of these functions in this tutorial, but before we recommend to assimilate well certain concepts related to programming. For it, take look our basic theme.

The Actions Panel


  In Flash, the Actions Panel is used to program scripts with ActionScript. It means, that everything what we introduce in this Panel will be reflected later in our movie. We must know clearly from the beginning that the Actions Panel can make reference to Frames or objects, so that introduced ActionScript code will affect only to what is refered in the Panel. For example, in the below image, it is possible to distinguish that the Actions Panel refers to Frame 1 of the Layer 1.

The Actions Panel is divided in 2 parts, on the left we have a help facilitated by Flash that gives us access fastly and very comfortably to all the actions, objects, properties etc... that Flash has predefined. These elements are divided in folders, that contain more folders classifying effectively everything what Flash places at our disposal. To insert them in our script it will be enough to double click the chosen element.

Later we'll see in detail the different elements from this Panel.

On the right side we have the space to place our script, here will appear what we are inserting. It also includes utility tools, like the search of words, the possibility of inserting break points, the tool to Review Syntax and the Flash help for ActionScript.

The Actions Panel of Flash MX 2004, in contrast, to the one Flash MX one, has only an edit mode, that has much more in common with the Expert Mode of Flash MX than with the Normal Mode.

Given that Flash MX 2004 has eliminated the Normal Mode of edition of scripts, the most inexperienced users will not have the help that provided this work style, and they will have to use the only existing panel.

The Actions Panel is, therefore, appropriate when we already have experience with programming with ActionScript, usually when we don't comment syntax errors and know well the Actions and Options that Flash provides us with.

This freedom type is total and therefore, it is also the possibility of commenting errors to ensure that our script is correct, while entering Expert Mode an icon will appear as: When pressing it Flash reviews our code looking for possible errors, indicating us, in its case, the line that presents the error and in what it consists.

It is a common error to waste hours looking why our movie is not working correctly while the reason is that a syntax error disabling all the code existing in a frame, that acts like if there were no CODE in it. Let’s keep in mind this and review the code conscientiously.


Legal warning: Authorised on-line use only. It is not allowed the use of these courses in companies or private teaching centres.
© aulaClic. All rights reserved. Reproduction in any form whatsoever is prohibited.