Basic debugging
85
Locating the problem
Do the following to start locating a problem:
•
Think backwards through the chain to identify where the unexpected started to happen.
•
Use the Message window to trace which frames the movie goes through and the handlers
that your scripts run.
•
Determine what the scripts should be doing and consider what in these statements relates to
the problem. For example, if a text cast member is not editable when you expect it to be, where
in the movie does (or does not) your script set the cast member’s
editable
property?
•
If a sprite does not change as intended on the Stage, is the
updateStage()
method needed
somewhere?
•
Does the problem occur only on certain computers and not others? Does it happen only when
the display is set to millions of colors? Maybe something in the computer is interfering with
the application.
You can focus on specific lines of script by inserting a breakpoint—a point where the script pauses
its execution and invokes the Debugger window—in a line. This gives you a chance to analyze
conditions at that point before the script proceeds. For information on how to insert breakpoints
in a script, see
“Debugging in the Debugger window” on page 94
.
Solving simple problems
When finding a bug, it’s a good idea to check for simple problems first.
The first debugging test occurs when you compile your script. You can compile your script by
doing one of the following:
•
In the Script window, click Recompile All Modified Scripts.
•
From the Control menu, click Recompile All Scripts.
•
Press Shift+F8.
•
Close the Script window.
It is typically more convenient to compile scripts by using one of the first three options. The
fourth option requires that you close the Script window each time you want to compile a script.
When you compile your script, Macromedia Director MX 2004 gives you an error message if the
script contains incorrect syntax. The message usually includes the line in which the problem was
first detected. A question mark appears at the spot in the line where Director first found
the problem.
For example, the first line in the previous error message tells you that the script error in question
is a syntax error, and also tells you what the syntax error is. The second line in the error message
displays the actual line of code that contains the syntax error.
Summary of Contents for DIRECTOR MX 2004
Page 1: ...DIRECTOR MX 2004 Director Scripting Reference...
Page 48: ...48 Chapter 2 Director Scripting Essentials...
Page 100: ...100 Chapter 4 Debugging Scripts in Director...
Page 118: ...118 Chapter 5 Director Core Objects...
Page 594: ...594 Chapter 12 Methods...
Page 684: ...684 Chapter 14 Properties See also DVD...
Page 702: ...702 Chapter 14 Properties See also face vertices vertices flat...
Page 856: ...856 Chapter 14 Properties JavaScript syntax sprite 15 member member 3 4...
Page 1102: ...1102 Chapter 14 Properties...