!= (inequality)
85
Description
Operator (inequality); tests for the exact opposite of the equality (
==
) operator. If
expression1
is
equal to
expression2
, the result is
false
. As with the
equality (
==
) operator, the definition of
equal
depends on the data types being compared, as illustrated in the following list:
•
Numbers, strings, and Boolean values are compared by value.
•
Objects, arrays, and functions are compared by reference.
•
A variable is compared by value or by reference, depending on its type.
Comparison by value means what most people would expect
equals
to mean—that two
expressions have the same value. For example, the expression (2 + 3) is equal to the expression
(1 + 4) when compared by value.
Comparison by reference means that two expressions are equal only if they both refer to the same
object, array, or function. Values inside the object, array, or function are not compared.
When comparing by value, if
expression1
and
expression2
are different data types,
ActionScript will attempt to convert the data type of
expression2
to match that of
expression1
. For more information, see
“Automatic data typing” on page 24
and
“Operator
precedence and associativity” on page 32
.
Example
The following example illustrates the result of the inequality (
!=
) operator:
trace(5 != 8);// returns true
trace(5 != 5) //returns false
The following example illustrates the use of the inequality (
!=
) operator in an
if
statement:
var a:String = "David";
var b:String = "Fool";
if (a != b) {
trace("David is not a fool");
}
The following example illustrates comparison by reference with two functions:
var a:Function = function() {
trace("foo");
};
var b:Function = function() {
trace("foo");
};
a(); // foo
b(); // foo
trace(a!=b); // true
a = b;
a(); // foo
b(); // foo
trace(a!=b); // false
// trace statement output:
foo
foo
Summary of Contents for FLEX-FLEX ACTIONSCRIPT LANGUAGE
Page 1: ...Flex ActionScript Language Reference...
Page 8: ......
Page 66: ...66 Chapter 2 Creating Custom Classes with ActionScript 2 0...
Page 76: ......
Page 133: ...break 133 See also for for in do while while switch case continue throw try catch finally...
Page 135: ...case 135 See also break default strict equality switch...
Page 146: ...146 Chapter 5 ActionScript Core Language Elements See also break continue while...
Page 808: ...808 Chapter 7 ActionScript for Flash...
Page 810: ...810 Appendix A Deprecated Flash 4 operators...
Page 815: ...Other keys 815 Num Lock 144 186 187 _ 189 191 192 219 220 221 222 Key Key code...
Page 816: ...816 Appendix B Keyboard Keys and Key Code Values...
Page 822: ...822 Index...