The following table lists the ActionScript numeric operators:
Operator
Operation performed
Addition
+
*
Multiplication
Division
/
Modulo (remainder of division)
%
Subtraction
-
++
Increment
Decrement
--
Comparison operators
Comparison operators compare the values of expressions and return a Boolean value (
). These operators are most commonly used in loops and in conditional statements. In the
false
following example, if the variable
SWF file loads:
if (score > 100){
loadMovieNum("winner.swf", 5);
} else {
loadMovieNum("loser.swf", 5);
}
The following table lists the ActionScript comparison operators:
Operator
Operation performed
Less than
<
Greater than
>
<=
Less than or equal
Greater than or equal
>=
String operators
The
operator has a special effect when it operates on strings: it concatenates the two string
+
operands. For example, the following statement adds
"Congratulations, " + "Donna!"
The result is
"Congratulations, Donna!"
Flash converts the other operand to a string.
The comparison operators
These operators compare two strings to determine which is first in alphabetical order.
The comparison operators only compare strings if both operands are strings. If only one of
the operands is a string, ActionScript converts both operands to numbers and performs a
numeric comparison.
46
Chapter 2: ActionScript Basics
is
, a certain SWF file loads; otherwise, a different
score
100
If only one of the
,
,
, and
also have a special effect when operating on strings.
>
>=
<
<=
"Congratulations,"
operator's operands is a string,
+
or
true
to
:
"Donna!"
Need help?
Do you have a question about the FLASH MX 2004 - ACTIONSCRIPT and is the answer not in the manual?