EasyManua.ls Logo

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT - Page 28

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT
816 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
28 Chapter 2: ActionScript Basics
Instance names are unique names that let you 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 SWF file could have the instance names
scorePlayer1_mc and scorePlayer2_mc. The
following code sets a variable called
score inside each movie clip instance by using
instance names:
_root.scorePlayer1_mc.score += 1;
_root.scorePlayer2_mc.score -= 1;
You can use special suffixes when naming instances so that code hints (see “Using code hints
on page 63) appear as you type your code. For more information, see “Using suffixes to trigger
code hints” on page 62.
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. For a list of keywords, see “Keywords” on page 33.
Methods are functions associated with a class. For example, getBytesLoaded() is a built-in
method associated with the MovieClip 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() becomes a method of a controller object that you
have previously defined:
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;
}
Packages
are directories that contain one or more class files, and reside in a designated classpath
directory (see “Understanding the classpath” on page 169).
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.

Table of Contents

Related product manuals