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.

Test the code again, <strong>and</strong> you see the following output:<br />

craig.dance = true craig.age = 32 craig.name = Craiggers<br />

See also<br />

class statement<br />

else statement<br />

if (condition){ statement(s); } else { statement(s); }<br />

Specifies the statements to run if the condition in the if statement returns false. The curly<br />

braces ({}) used to enclose the block of statements to be executed by the else statement are<br />

not necessary if only one statement will execute.<br />

Parameters<br />

condition:Boolean - An expression that evaluates to true or false.<br />

Example<br />

In the following example, the else condition is used to check whether the age_txt variable is<br />

greater than or less than 18:<br />

if (age_txt.text>=18) { trace("welcome, user"); } else { trace("sorry,<br />

junior"); userObject.minor = true; userObject.accessAllowed = false; }<br />

In the following example, curly braces ({}) are not necessary because only one statement<br />

follows the else statement:<br />

if (age_txt.text>18) { trace("welcome, user"); } else trace("sorry,<br />

junior");<br />

See also<br />

ifFrameLoaded function<br />

else if statement<br />

if (condition){ statement(s); }<br />

else if (condition){ statement(s);}<br />

Evaluates a condition <strong>and</strong> specifies the statements to run if the condition in the initial if<br />

statement returns false. If the else if condition returns true, the Flash interpreter runs<br />

the statements that follow the condition inside curly braces ({}). If the else if condition is<br />

false, Flash skips the statements inside the curly braces <strong>and</strong> runs the statements following<br />

the curly braces.<br />

178 ActionScript language elements

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

Saved successfully!

Ooh no, something went wrong!