03.05.2013 Views

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Oper<strong>and</strong>s<br />

expression1 : Object - A number, string, Boolean value, variable, object, array, or<br />

function.<br />

expression2 : Object - A number, string, Boolean value, variable, object, array, or<br />

function.<br />

Returns<br />

Boolean - The Boolean result of the comparison.<br />

Example<br />

The comments in the following code show the returned value of operations that use the<br />

equality <strong>and</strong> strict equality operators:<br />

// Both return true because no conversion is done<br />

var string1:String = "5";<br />

var string2:String = "5";<br />

trace(string1 == string2); // true<br />

trace(string1 === string2); // true<br />

// Automatic data typing in this example converts 5 to "5"<br />

var string1:String = "5";<br />

var num:Number = 5;<br />

trace(string1 == num); // true<br />

trace(string1 === num); // false<br />

// Automatic data typing in this example converts true to "1"<br />

var string1:String = "1";<br />

var bool1:Boolean = true;<br />

trace(string1 == bool1); // true<br />

trace(string1 === bool1); // false<br />

// Automatic data typing in this example converts false to "0"<br />

var string1:String = "0";<br />

var bool2:Boolean = false;<br />

trace(string1 == bool2); // true<br />

trace(string1 === bool2); // false<br />

The following examples show how strict equality treats variables that are references differently<br />

than it treats variables that contain literal values. This is one reason to consistently use String<br />

literals <strong>and</strong> to avoid the use of the new operator with the String class.<br />

// Create a string variable using a literal value<br />

var str:String = "asdf";<br />

// Create a variable that is a reference<br />

var stringRef:String = new String("asdf");<br />

// The equality operator does not distinguish among literals, variables,<br />

// <strong>and</strong> references<br />

trace(stringRef == "asdf"); // true<br />

trace(stringRef == str); // true<br />

trace("asdf" == str); // true<br />

Operators 159

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!