EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Page 142

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
142 Syntax and Language Fundamentals
For more information on each statement, see the following topics:
About compound statements” on page 142
About conditions on page 142
“Repeating actions using loops on page 153
About compound statements
A compound statement contains numerous statements that you enclose within curly brace
(
{}) punctuators. The statements inside a compound statement can be any kind of
ActionScript statement. A typical compound statement is shown below.
The statements within the curly brace punctuators are indented from the compound
statement, as the following ActionScript shows:
var a:Number = 10;
var b:Number = 10;
if (a == b) {
// This code is indented.
trace("a == b");
trace(a);
trace(b);
}
This compound statement contains several statements, but acts like a single statement in your
ActionScript code. The opening brace is placed at the end of the compound statement. The
closing brace begins a line, and aligns with the beginning of the compound statement.
For more information on using braces, see “Curly braces on page 126.
About conditions
You use conditions to determine whether something is true or exists, and then you can
optionally repeat an action (using loops), or execute actions that you specify, such as functions
or expressions, based on whether the condition is true or not. For example, you can determine
whether a certain variable is defined or has a certain value and execute a block of code based
on the result. Also, you could change the graphics within your Flash document based on what
time the user's system clock is set to or on the weather in the users current location.
To perform an action depending on whether a condition exists, or to repeat an action (create
loop statements), you can use
if, else, else if, for, while, do while, for..in, or switch
statements.

Table of Contents

Related product manuals