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.

i = 0, j = 0<br />

// i = 1, j = 2<br />

The following example uses the comma (,) operator without the parentheses () operator <strong>and</strong><br />

illustrates that the comma operator returns only the value of the first expression without the<br />

parentheses () operator:<br />

var v:Number = 0;<br />

v = 4, 5, 6;<br />

trace(v); // output: 4<br />

The following example uses the comma (,) operator with the parentheses () operator <strong>and</strong><br />

illustrates that the comma operator returns the value of the last expression when used with the<br />

parentheses () operator:<br />

var v:Number = 0;<br />

v = (4, 5, 6);<br />

trace(v); // output: 6<br />

The following example uses the comma (,) operator without the parentheses () operator <strong>and</strong><br />

illustrates that the comma operator sequentially evaluates all of the expressions but returns the<br />

value of the first expression. The second expression, z++, is evaluated <strong>and</strong> z is incremented by<br />

one.<br />

var v:Number = 0;<br />

var z:Number = 0;<br />

v = v + 4 , z++, v + 6;<br />

trace(v); // output: 4<br />

trace(z); // output: 1<br />

The following example is identical to the previous example except for the addition of the<br />

parentheses () operator <strong>and</strong> illustrates once again that, when used with the parentheses ()<br />

operator, the comma (,) operator returns the value of the last expression in the series:<br />

var v:Number = 0;<br />

var z:Number = 0;<br />

v = (v + 4, z++, v + 6);<br />

trace(v); // output: 6<br />

trace(z); // output: 1<br />

See also<br />

() parentheses operator<br />

add concatenation (strings) operator<br />

string1 add string2<br />

Deprecated since Flash Player 5. <strong>Adobe</strong> recommends you use the addition (+) operator when<br />

creating content for Flash Player 5 or later.<br />

130 ActionScript language elements

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

Saved successfully!

Ooh no, something went wrong!