5.
Select Control > Test Movie again.
The string
It equals 2
6.
Return to the authoring environment and change:
if (myNum == 2) {
to
if (myNum = 2) {
7.
Select Control > Test Movie again.
The string
It equals 2
In step 6, you assign the value of
case, the
statement executes regardless of the previous value of
if
unexpected results when you test the Flash document.
For more information on correctly using the assignment operator, see
operators" on page
The strict equality operator (
type conversion. If two operands are different types, the equality operator returns
strict inequality operator (
The following ActionScript demonstrates the key difference between the equality operator
(
) and the strict equality operator (
==
var num1:Number = 32;
var num2:String = new String("32");
trace(num1 == num2); // true
trace(num1 === num2); // false
First, you define numeric variables:
equality operator, Flash tries to convert the values to the same data type and then compare the
values to see whether they are equal. When you use the strict equality operator (
doesn't attempt to do any data type conversion before it compares the values. As a result, Flash
sees the variables as two separate values.
In the following example, you'll use the greater than or equal to (
values and execute code based on the value a user enters into a text field.
doesn't appear in the Output panel.
appears in the Output panel again.
to
2
myNum
194.
) is similar to the equality operator, except it doesn't perform
===
) returns the opposite of the strict equality operator.
!==
):
===
, and
num1
, instead of comparing
. If you compare the variables using the
num2
>=
to
. In this
myNum
2
, which can cause
myNum
"Using assignment
. The
false
) Flash
===
) operator to compare
About operators
191
Need help?
Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?