Identifiers
are names used to indicate a variable, property, object, function, or method. The first
character must be a letter, underscore (
letter, number, underscore, or dollar sign. For example,
Instances
are objects that contain all the properties and methods of a particular class. For
example, all arrays are instances of the Array class, so you can use any of the methods or properties
of the Array class with any array instance.
Instance names
following code, "names" and "studentName" are instance names for two objects, an array and a
string:
var names:Array = new Array();
var studentName:String = new String();
Keywords
are reserved words that have special meaning. For example,
declare local variables. You cannot use a keyword as an identifier. For example,
variable name. For a list of keywords, see
Methods
are functions associated with a class. For example,
associated with the Array class. You can also create functions that act as methods, either for
objects based on built-in classes or for objects based on classes that you create. For example, in the
following code,
clear()
defined:
function reset(){
this.x_pos = 0;
this.y_pos = 0;
}
controller.clear = reset;
controller.clear();
The following examples show how you create methods of a class:
//ActionScript 1 example
A = new Object();
A.prototype.myMethod = function() {
trace("myMethod");
}
//ActionScript 2 example
class B {
function myMethod() {
trace("myMethod");
}
}
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 class 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.
12
Chapter 1: ActionScript Basics
_
are unique names that let you target instances you create. For example, in the
becomes a method of a
), or dollar sign (
). Each subsequent character must be a
$
firstName
"Keywords and reserved words" on page
sortOn()
controller
is the name of a variable.
is a keyword used to
var
is not a legal
var
17.
is a built-in method
object that you have previously
Need help?
Do you have a question about the FLEX-FLEX ACTIONSCRIPT LANGUAGE and is the answer not in the manual?