In Director MX, bugs inevitably appear as error messages. Figure 19.7 is an example of this. A button has been clicked and the error message box appears. The important items in this dialog box are the Debug button and the Script button. Figure 19.7. A typical error message in Director MX shows you the error and the Script and Debug buttons .
In addition to the Script and Debug windows , you also have available to you the Compile button in the Script window, the watcher, and the Message window. Using the Director MX DebuggerIf ever there was a feature in Director MX that will trip up the "newbie," it has to be this one. Up pops the error, and the first reaction is to click the Debug button in the mistaken assumption that Director will somehow fix the code. It won't happen. The purpose of the Debug window is to show you where the problem occurred and nothing more. There are actually two occasions where the Debugger is an invaluable tool. The first is when you get an error message. The second is when you need to set a breakpoint. Follow these steps to use the Debug button:
Note We can hear the veteran Director MX developers sighing and saying, "Oh man." We agree; using the Debugger for such a simple error is overkill. This feature really shines when variable values and handlers are being used for some rather complex coding. Using the Script WindowThe Script Window is where scripts are entered in Director MX. When you click the button to get the error message, you will notice the Script Error window not only tells you it can't find a Property, it shows you the line of code and the Property#clickOnthat couldn't be found. In this instance, click the Script button because you are dealing with a spelling error. Follow these steps to fix the problem in the Script window:
Tip A very common coding error is a spelling mistake. These usually result in an error that tells you a variable doesn't have a value. A good habit to get into is to compile the script before closing the Script window. The Compile button is on the Button bar and looks like a lightning bolt. When the script is finished, click it, and if there is a problem, you will see an error message like that shown in Figure 19.10. In this instance, a space was added between "mouse" and "Up." Figure 19.10. Clicking the Compile buttonthe lightning boltbefore saving the script will catch syntax errors.
|