Chapter 16
426
Troubleshooting Lingo
Scripts don’t always do what you want the first time. The script often has an error in its syntax:
possibly a word is misspelled or a small part of the script is missing. Other times the script might
work but doesn’t produce the expected result.
Mistakes or bugs almost always occur when writing Lingo, so you should allow enough time for
debugging when you develop multimedia titles.
As your skill with Lingo increases, you’ll probably encounter different types of problems as you
master one area but start learning others. However, the basic troubleshooting techniques
described in this section are useful for novice and advanced users alike.
The best way to correct a Lingo bug varies from situation to situation. There aren’t one or two
standard procedures that resolve the problem. You need to use a variety of tools and techniques,
such as the following:
•
An overview and understanding of how scripts in the movie interact with each other
•
Familiarity and practice with common debugging methods
The following tools help you identify problems in Lingo:
•
The Message window, when tracing is on, displays a record of the frames that play and the
handlers that run in the movie.
•
The Debugger window displays the Lingo that is currently running, the sequence of
handlers that Lingo ran to get to its current point, and the value of variables and expressions
that you select.
•
The Script window lets you enter comments, insert stopping points in the script, and select
variables whose value is displayed in the Object inspector.
•
The Object inspector lets you view and set the values of objects and properties you select.
Good scripting habits
Good scripting habits can help you avoid many Lingo problems in the first place.
•
Try to write Lingo in small sets of statements and test each one as you write it. This isolates
potential problems where they are easier to identify.
•
Insert comments that explain what the Lingo statements are intended to do and what the
values in the script are for. This makes it easier to understand the script if you return to it later
or if someone else works on it. For example, the comments in these Lingo statements make the
purpose of this
if…then
statement and repeat loop clear:
if the soundLevel = 0 then
-- Loop for 4 seconds (240 ticks)
startTimer
repeat while the timer < 240
end repeat
end if
•
Make sure that Lingo syntax is correct. Use the Script window’s Lingo menu to insert
preformatted versions of Lingo elements. Rely on the Lingo Dictionary to check that statements
are set up correctly.
•
Use variable names that indicate the variables’ purpose. For example, a variable that contains a
number should be called something like
newNumber
instead of
ABC
.
Summary of Contents for DIRECTOR MX-USING DIRECTOR MX
Page 1: ...Using Director MX Macromedia Director MX...
Page 12: ...Contents 12...
Page 156: ...Chapter 4 156...
Page 202: ...Chapter 6 202...
Page 244: ...Chapter 7 244...
Page 292: ...Chapter 10 292...
Page 330: ...Chapter 12 330...
Page 356: ...Chapter 13 356...
Page 372: ...Chapter 14 372...
Page 442: ...Chapter 16 442...
Page 472: ...Chapter 18 472...
Page 520: ...Chapter 19 520...
Page 536: ...Chapter 20 536...
Page 562: ...Chapter 23 562...
Page 566: ...Chapter 24 566...
Page 602: ...Chapter 27 602...