Understanding the ActionScript Language > ActionScript terminology |  |

ActionScript terminology

Like any scripting language, ActionScript uses its own terminology. The following list provides an introduction to important ActionScript terms in alphabetical order.

Actions are statements that instruct a movie to do something while it is playing. For example, `gotoAndStop` sends the playhead to a specific frame or label. In this manual, the terms action and statement are interchangeable.

Boolean is a true or false value.

Classes are data types that you can create to define a new type of object. To define a class, you create a constructor function.

Constants are elements that don't change. For example, the constant `Key.TAB` always has the same meaning: it indicates the Tab key on a keyboard. Constants are useful for comparing values.

Constructors are functions that you use to define the properties and methods of a class. For example, the following code creates a new Circle class by creating a constructor function called `Circle`:

    function Circle(x, y, radius){
    	this.x = x;
    	this.y = y;
    	this.radius = radius;
    }

Data types are a sets of values and the operations that can be performed on them. The ActionScript data types are string, number, boolean, object, movieclip, function, null, and undefined. For more details on these language elements, see About data types.

Events are actions that occur while a movie is playing. For example, different events are generated when a movie clip loads, the playhead enters a frame, the user clicks a button or movie clip, or the user types at the keyboard.

Event handlers are special actions that manage events such as `mouseDown` or `load`. There are two kinds of ActionScript event handlers: actions and methods. There are only two event handler actions, `on` and `onClipEvent`. In the Actions toolbox, each ActionScript object that has event handler methods has a subcategory called Events.

Expressions are any legal combination of ActionScript symbols that represent a value. An expression consists of operators and operands. For example, in the expression `x + 2`, `x` and `2` are operands and `+` is an operator.

Functions are blocks of reusable code that can be passed parameters and can return a value. For example, the `getProperty` function is passed the name of a property and the instance name of a movie clip, and it returns the value of the property. The `getVersion` function returns the version of the Flash Player currently playing the movie.

Identifiers are names used to indicate a variable, property, object, function, or method. The first character must be a letter, underscore (`_`), or dollar sign (`$`). Each subsequent character must be a letter, number, underscore, or dollar sign. For example, `firstName` is the name of a variable.

Instances are objects that belong to a certain class. Each instance of a class contains all the properties and methods of that class. All movie clips are instances with properties (for example, `_alpha` and `_visible`) and methods (for example, `gotoAndPlay` and `getURL`) of the MovieClip class.

Instance names are unique names that allow you to target movie clip and button instances in scripts. You use the Property inspector to assign instance names to instances on the Stage. For example, a master symbol in the library could be called `counter` and the two instances of that symbol in the movie could have the instance names `scorePlayer1` and `scorePlayer2`. The following code sets a variable called `score` inside each movie clip instance by using instance names:

    _root.scorePlayer1.score += 1;
    _root.scorePlayer2.score -= 1;

Keywords are reserved words that have special meaning. For example, `var` is a keyword used to declare local variables. You cannot use a keyword as an identifier. For example, `var` is not a legal variable name.

Methods are functions assigned to an object. After a function is assigned, it can be called as a method of that object. For example, in the following code, `clear` becomes a method of the `controller` object:

    function reset(){
    	this.x_pos = 0;
    	this.x_pos = 0;
    }
    controller.clear = reset;
    controller.clear();

Objects are collections of properties and methods; each object has its own name and is an instance of a particular class. Built-in objects are predefined in the ActionScript language. For example, the built-in Date object provides information from the system clock.

Operators are terms that calculate a new value from one or more values. For example, the addition (`+`) operator adds two or more values together to produce a new value. The values that operators manipulate are called operands.

Parameters (also called arguments) are placeholders that let you pass values to functions. For example, the following `welcome` function uses two values it receives in the parameters `firstName` and `hobby`:

    function welcome(firstName, hobby) {
    	welcomeText = "Hello, " + firstName + "I see you enjoy " + hobby;
    }

Properties are attributes that define an object. For example, `_visible` is a property of all movie clips that defines whether a movie clip is visible or hidden.

Target paths are hierarchical addresses of movie clip instance names, variables, and objects in a movie. You name a movie clip instance in the movie clip Property inspector. (The main Timeline always has the name `_root`.) You can use a target path to direct an action at a movie clip or to get or set the value of a variable. For example, the following statement is the target path to the variable `volume` inside the movie clip `stereoControl`:

    _root.stereoControl.volume

Variables are identifiers that hold values of any data type. Variables can be created, changed, and updated. The values they store can be retrieved for use in scripts. In the following example, the identifiers on the left side of the equal signs are variables:

    x = 5;
    name = "Lolo";
    customer.address = "66 7th Street";
    c = new Color(mcinstanceName);