MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual page 147

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

3.
Select Control > Test Movie to test the ActionScript.
In this code, you create a string called
(for example, if it's 6:19 pm,
method of the Date class to get the current hour. Then you can use the
getHours()
statement to trace information to the Output panel, based on the number
if..else if
that returns. For more information, see the comments in the previous code snippet.
Using a switch statement
The
statement creates a branching structure for ActionScript statements. Similar to
switch
the
statement, the
if
condition returns a value of
When you use a
switch
statements in that case block and jump to the first statement that follows the enclosing
statement. If a case block doesn't contain a break statement, a condition called "fall
switch
through" occurs. In this situation, the following case statement also executes until a break
statement is encountered or the
following example, where the first case statement doesn't contain a break statement and
therefore both of the code blocks for the first two cases (A and B) execute.
All
statements should include a
switch
last case on a
switch
through error if another case is added. For example, if the condition in the following example
evaluates to A, both the statements for case A and B execute, because case A lacks a
statement. When a case falls through, it does not have a break statement, but includes a
comment in the
break
case A. Use the following format when you write
switch (condition) {
case A :
// statements
// falls through
case B :
// statements
break;
case Z :
// statements
break;
default :
// statements
break;
}
currentHour
currentHour
statement tests a condition and executes statements if the
switch
.
true
statement, the
break
statement ends. This behavior is demonstrated in the
switch
default
statement and should also include a
statement's place, which you can see in the following example after
that holds the current hour number
holds the number
18
statement instructs Flash to skip the rest of the
case. The
default
statement to prevent a fall-
break
statements:
switch
). You use the
case should always be the
break
About statements
147

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash 8

Table of Contents