•
If the user pressed any other letter key, the computer beeps.
-- Lingo syntax
case (_key.key) of
"a" : _movie.go("Apple")
"b", "c":
_movie.puppetTransition(99)
_movie.go("Oranges")
otherwise: _sound.beep()
end case
// JavaScript syntax
switch (_key.key) {
case "a" :
_movie.go("Apple");
break;
case "b":
_movie.puppetTransition(99);
_movie.go("Oranges");
break;
case "c":
_movie.puppetTransition(99);
_movie.go("Oranges");
break;
default: _sound.beep()
}
Note: In JavaScript syntax, only one comparison can be made per case statement.
For reference information on using
Repeating actions
In both Lingo and JavaScript syntax, you can repeat an action a specified number of times or
while a specific condition exists.
In Lingo, to repeat an action a specified number of times you use a
Specify the number of times to repeat as a range following
In JavaScript syntax, to repeat an action a specified number of times you use the
The
structure takes three parameters: the first parameter typically initializes a counter
for
variable, the second parameter specifies a condition to evaluate each time through the loop, and
the third parameter is typically used to update or increment the counter variable.
The
repeat with
objects. For example, the following loop makes Background Transparent the ink for sprites 2
through 10:
-- Lingo syntax
repeat with n = 2 to 10
sprite(n).ink = 36
end repeat
// JavaScript syntax
for (var n=2; n<=10; n++) {
sprite(n).ink = 36;
}
case
and
structures are useful for performing the same operation on a series of
for
structures, see
"case" on page
repeat with
203.
structure.
repeat with
.
structure.
for
Conditional constructs
31
Need help?
Do you have a question about the DIRECTOR MX 2004-DIRECTOR SCRIPTING and is the answer not in the manual?
Questions and answers