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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Comparison by reference means that two expressions are equal only if they both refer to the<br />

same object, array, or function. Values inside the object, array, or function are not compared.<br />

When comparing by value, if expression1 <strong>and</strong> expression2 are different data types,<br />

ActionScript will attempt to convert the data type of expression2 to match that of<br />

expression1.<br />

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 following example illustrates the result of the inequality (!=) operator:<br />

trace(5 != 8); // returns true<br />

trace(5 != 5) //returns false<br />

The following example illustrates the use of the inequality (!=) operator in an if statement:<br />

var a:String = "David";<br />

var b:String = "Fool";<br />

if (a != b) {<br />

trace("David is not a fool");<br />

}<br />

The following example illustrates comparison by reference with two functions:<br />

var a:Function = function() { trace("foo"); };<br />

var b:Function = function() { trace("foo"); };<br />

a(); // foo<br />

b(); // foo<br />

trace(a != b); // true<br />

a = b;<br />

a(); // foo<br />

b(); // foo<br />

trace(a != b); // false<br />

// trace statement output: foo foo true foo foo false<br />

The following example illustrates comparison by reference with two arrays:<br />

var a:Array = [ 1, 2, 3 ];<br />

var b:Array = [ 1, 2, 3 ];<br />

trace(a); // 1, 2, 3<br />

trace(b); // 1, 2, 3<br />

142 ActionScript language elements

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

Saved successfully!

Ooh no, something went wrong!