== (equality)

SWiSH Player Support
SWF5 or later - Supported Internally

Syntax
expression1 == expression2

Arguments
expression1, expression2: A number, string, boolean value, variable or function.

Returns
Nothing.

Description
Operator (equality); tests two expressions for equality. The result is true if the expressions are equal.

The definition of equal depends on the data type of the parameter:
  • If both of the two values are strings, they are compared as strings. Otherwise, any strings are converted to numbers before being compared.  

  • If the values are numbers, then the values are compared  


  • Note: For SWF4 only, comparing a variable and a string will assume the variable also contains a string, and will do a string comparison. For SWF5+ the actual type of value in the variable is used as above to determine how to compare.

    Sample
    x =  5 ;
    y =  6 ;
    trace(x == y);
      // returns (0), false

    These examples show the results of operations that compare mixed types.
    x = " 5 "; y = " 5 ";
    trace(x == y);
      // this works as variables are converted to numbers.
    // true
    // this works as variables are converted to numbers.

    x = " 5 "; y = " 66 ";
    trace(x ==y);

    // false
    // this works as variables are converted to numbers .

    x = "chris"; y = "steve";
    trace (x == y);

    // true
    // unexpected result caused by conversion of both strings constants to numeric (value = 0).
    // use ' eq ' operator  instead.