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.

var z = (x < 6) ? x: y;<br />

trace (z); // returns 5<br />

The following example shows a conditional statement written in shorth<strong>and</strong>:<br />

var timecode:String = (new Date().getHours() < 11) ? "AM" : "PM";<br />

trace(timecode);<br />

The same conditional statement could also be written in longh<strong>and</strong>, as shown in the following<br />

example:<br />

if (new Date().getHours() < 11) {<br />

var timecode:String = "AM";<br />

} else {<br />

var timecode:String = "PM";<br />

} trace(timecode);<br />

-- decrement operator<br />

--expression<br />

expression--<br />

A pre-decrement <strong>and</strong> post-decrement unary operator that subtracts 1 from the expression.<br />

The expression can be a variable, element in an array, or property of an object. The predecrement<br />

form of the operator (--expression) subtracts 1 from expression <strong>and</strong> returns<br />

the result. The post-decrement form of the operator (expression--) subtracts 1 from the<br />

expression <strong>and</strong> returns the initial value of expression (the value prior to the<br />

subtraction).<br />

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

expression : Number - A number or a variable that evaluates to a number.<br />

Returns<br />

Number - The result of the decremented value.<br />

Example<br />

The pre-decrement form of the operator decrements x to 2 ( x - 1 = 2) <strong>and</strong> returns the result<br />

as y:<br />

var x:Number = 3;<br />

var y:Number = --x; //y is equal to 2<br />

The post-decrement form of the operator decrements x to 2 (x - 1 = 2 ) <strong>and</strong> returns the<br />

original value of x as the result y:<br />

var x:Number = 3;<br />

var y:Number = x--; //y is equal to 3<br />

132 ActionScript language elements

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

Saved successfully!

Ooh no, something went wrong!