02.02.2013 Views

Flash MX 2004 Games : Art to ActionScript

Flash MX 2004 Games : Art to ActionScript

Flash MX 2004 Games : Art to ActionScript

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

the Watch window, then you can see how<br />

just these variables are behaving as you run<br />

through the code. There is also a ‘locals’ tab,<br />

which lists the variables that are declared in the<br />

current function.<br />

The but<strong>to</strong>ns above the script pane allow the<br />

developer <strong>to</strong> ‘Continue’, ‘S<strong>to</strong>p Debugging’,<br />

‘Toggle Breakpoint’, ‘Remove All Breakpoints’,<br />

‘Step Over’, ‘Step In’ and ‘Step Out’.<br />

The last three allow the developer the ability <strong>to</strong><br />

study at close quarters how the code behaves.<br />

Chapter 11: Debugging<br />

Figure 11.9 Debugger <strong>to</strong>olbar<br />

Step Over executes a single line of code in the current function.<br />

Step In will take the playback head in<strong>to</strong> a user-defined function if there is such a call on<br />

the current line of code. Once inside the function you can use Step Over <strong>to</strong> examine<br />

how the code behaves a line at a time.<br />

Step Out only applies <strong>to</strong> a user-defined function. If the code pointer is currently inside<br />

a user-defined function then that function is executed until there is a return from the<br />

function, at which time the program halts.<br />

Stepping through the code can be a very effective way of tracking down a persistent problem.<br />

Remote debugging<br />

You can even use the debugger <strong>to</strong> analyse a remote file on a web server. To enable remote<br />

debugging you must ensure that you have taken two important steps.<br />

Step 1<br />

Enable remote debugging of the movie by selecting ‘File/Publish Settings’. The dialog box shown<br />

in Figure 11.10 appears. Make sure that you have checked the box that says ‘Debugging Permitted’.<br />

If necessary you can enter a password in the dialog box <strong>to</strong> make your file more secure. Then<br />

publish your movie.<br />

Step 2<br />

When you publish the movie, <strong>Flash</strong> creates a file with the extension ‘swd’; this file has the same<br />

name as the ‘swf’ file. It is essential that the ‘swd’ file be in the same location as the ‘swf’ file<br />

for remote debugging <strong>to</strong> work fully. Without the ‘swd’ file <strong>Flash</strong> will not be able <strong>to</strong> s<strong>to</strong>p at a<br />

breakpoint or step through the code a line at a time.<br />

Having made sure that you enabled debugging and that the ‘swd’ file resides at the same<br />

URL as the ‘swf’ file, you are now ready <strong>to</strong> use remote debugging. Open the Debugger<br />

window using ‘Window/Development Panels/Debugger’. Click the options icon in the <strong>to</strong>p<br />

right corner and make sure ‘Enable Remote Debugging’ is checked. Try running the file:<br />

‘Examples/Chapter11/Remote.html’.<br />

165

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!