Advanced debugging
99
Advanced debugging
If the problem is not easy to identify, try the following approaches:
•
Determine which section has the problem. For example, if clicking a button produces the
wrong result, investigate the script assigned to the button.
If a sprite does the wrong thing, try checking the sprite’s property values. Are they set to the
values you want when you want?
•
Figure out where the script flows. When a section of the movie does not do what you want,
first try to trace the movie’s sequence of events in your head. Look at other scripts in the
message hierarchy to make sure Director is running the correct handler.
•
Follow the tracing in the Message window; this shows which frames the movie goes through
and any handlers that the movie calls as the movie plays.
•
Try using the Step Script and Step Into features in the Debugger window and see whether the
results differ from what you expect.
•
Check variables and expressions. Analyze how their values change as the movie plays. See if
they change at the wrong time or do not change at all. If the same variable is used in more than
one handler, make sure that each handler that uses the variable states that the variable is global.
You can track the values of variables and expressions by displaying their values in the Watcher
pane of the Debugger window or the Object inspector.
•
Make changes one at a time. Don’t be afraid to change things in a handler to see if the change
eliminates the problem or gives some result that helps point to the problem.
However, do not trade one problem for another. Change things one at a time and change them
back if the problem is not fixed. If you introduce too many changes before solving a problem,
you might not determine what the original problem was and you might even introduce
new problems.
•
Re-create the section. If you have not found the problem, try re-creating the section from
scratch. For example, if rolling the pointer over a sprite does not make the sprite behave the
way you want, create a simple movie that contains just the sprite and handler with the
rollOver()
method.
Do not just copy and paste scripts; that might just copy the problem. Re-creating the section
lets you reconstruct the logic at its most basic level and verify that Director is working as you
expect. If the section that you re-create still does not work properly, chances are that there is
something wrong in the logic for the section.
If the section that you re-create works properly, compare that section to the original movie to
see where the two differ. You can also copy the section into the original piece and see whether
this corrects the problem.
Summary of Contents for DIRECTOR MX 2004-DIRECTOR SCRIPTING
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...