EasyManua.ls Logo

MACROMEDIA DIRECTOR MX-USING DIRECTOR MX - Repeating an action

MACROMEDIA DIRECTOR MX-USING DIRECTOR MX
624 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...
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

Table of Contents