MACROMEDIA FLEX-FLEX ACTIONSCRIPT LANGUAGE Reference page 172

Actionscript language reference
Table of Contents

Advertisement

if
Availability
Flash Player 4.
Usage
if(condition) {
statement(s);
}
Parameters
An expression that evaluates to
condition
statement(s)
Returns
Nothing.
Description
Statement; evaluates a condition to determine the next action in a SWF file. If the condition is
, Flash runs the statements that follow the condition inside curly braces (
true
is
, Flash skips the statements inside the curly braces and runs the statements following the
false
curly braces. Use the
branching logic in your scripts.
The curly braces (
are not necessary if only one statement will execute.
Example
The following example uses an
instance in a SWF file. If a user clicks the button more than 10 seconds after the
submit_btn
SWF file plays, the condition evaluates to
appears in a text field that's created at runtime (using
button less than 10 seconds after the SWF file plays, the condition evaluates to
different message appears.
this.createTextField("message_txt", this.getNextHighestDepth, 0, 0, 100, 22);
message_txt.autoSize = true;
var startTime:Number = getTimer();
this.submit_btn.onRelease = function() {
var difference:Number = (getTimer()-startTime)/1000;
if (difference>10) {
this._parent.message_txt.text = "Not very speedy, you took "+difference+"
seconds.";
} else {
this._parent.message_txt.text = "Very good, you hit the button in
"+difference+" seconds.";
}
};
See also
else
172
Chapter 5: ActionScript Core Language Elements
ActionScript Core Language Elements
The instructions to execute if or when the condition evaluates to
statement along with the
if
) used to enclose the block of statements to be executed by the
{}
statement to evaluate how long it takes a user to click the
if
or
.
true
false
and
else
else if
and the message inside the curly braces (
true
createTextField()
CHAPTER 5
.
true
). If the condition
{}
statements to create
statement
if
)
{}
). If the user clicks the
and a
false

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLEX-FLEX ACTIONSCRIPT LANGUAGE and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flex

Table of Contents