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.

Parameters<br />

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

Example<br />

In the following example, the condition inside the parentheses evaluates the variable name to<br />

see if it has the literal value "Erica". If it does, the play() function inside the curly braces<br />

runs.<br />

if(name == "Erica"){<br />

play();<br />

}<br />

The following example uses an if statement to evaluate how long it takes a user to click the<br />

submit_btninstance in a SWF file. If a user clicks the button more than 10 seconds after the<br />

SWF file plays, the condition evaluates to true <strong>and</strong> the message inside the curly braces ({})<br />

appears in a text field that's created at runtime (using createTextField()). If the user clicks<br />

the button less than 10 seconds after the SWF file plays, the condition evaluates to false <strong>and</strong><br />

a different message appears.<br />

this.createTextField("message_txt", this.getNextHighestDepth, 0, 0, 100,<br />

22);<br />

message_txt.autoSize = true;<br />

var startTime:Number = getTimer();<br />

this.submit_btn.onRelease = function() {<br />

var difference:Number = (getTimer() - startTime) / 1000;<br />

if (difference > 10) {<br />

this._parent.message_txt.text = "Not very speedy, you took "+difference+"<br />

seconds.";<br />

}<br />

else {<br />

this._parent.message_txt.text = "Very good, you hit the button in<br />

"+difference+" seconds.";<br />

}<br />

};<br />

See also<br />

else statement<br />

implements statement<br />

myClass implements interface01 [, interface02 , ...]<br />

Note: To use this keyword, you must specify ActionScript 2.0 <strong>and</strong> Flash Player 6 or later in<br />

the Flash tab of your FLA file's Publish Settings dialog box. This keyword is supported only<br />

when used in external script files, not in scripts written in the Actions panel.<br />

Statements 187

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

Saved successfully!

Ooh no, something went wrong!