Writing Scripts with Lingo
411
For example, the following
case
statement tests which key the user pressed most recently and
responds accordingly:
case (the key) of
"A": go to frame "Apple"
"B", "C":
puppetTransition 99
go to frame "Oranges"
otherwise beep
end case
•
If the user pressed A, the movie goes to the frame labeled Apple.
•
If the user pressed B or C, the movie performs the specified transition and then goes to the
frame labeled Oranges.
•
If the user pressed any other letter key, the computer beeps.
A
case
statement can use comparisons as the test condition.
For more information, see
case
in the Lingo Dictionary.
Repeating an action
Lingo can repeat an action a specified number of times or while a specific condition exists.
To repeat an action a specified number of times:
•
Use a
repeat with
structure. Specify the number of times to repeat as a range following
repeat with
.
This structure is useful for performing the same operation on a series of objects. For example, the
following repeat loop makes Background Transparent the ink for sprites 2 through 10:
repeat with n = 2 to 10
set the ink of sprite n = 36
end repeat
This example performs exactly the same action as above, but uses dot syntax:
repeat with n = 2 to 10
sprite(n).ink = 36
end repeat
This example performs a similar action, but with decreasing numbers:
repeat with n = 10 down to 2
sprite(n).ink = 36
end repeat
To repeat a set of instructions as long as a specific condition exists:
•
Use a
repeat...while
statement.
For example, these statements instruct a movie to beep continuously whenever the mouse button
is being pressed:
repeat while the mouseDown
beep
end repeat
Содержание DIRECTOR MX-USING DIRECTOR MX
Страница 1: ...Using Director MX Macromedia Director MX...
Страница 12: ...Contents 12...
Страница 156: ...Chapter 4 156...
Страница 202: ...Chapter 6 202...
Страница 244: ...Chapter 7 244...
Страница 292: ...Chapter 10 292...
Страница 330: ...Chapter 12 330...
Страница 356: ...Chapter 13 356...
Страница 372: ...Chapter 14 372...
Страница 442: ...Chapter 16 442...
Страница 472: ...Chapter 18 472...
Страница 520: ...Chapter 19 520...
Страница 536: ...Chapter 20 536...
Страница 562: ...Chapter 23 562...
Страница 566: ...Chapter 24 566...
Страница 602: ...Chapter 27 602...