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.

10 name = "Box" + i;<br />

11 eval(name)._x = n;<br />

12 eval(name)._y = 100;<br />

13<br />

14 }<br />

}<br />

Listing 11.7 ‘Examples/Chapter11/debug11.fla’<br />

Chapter 11: Debugging<br />

Program execution<br />

Never assume you know what is going on under the hood. Some of the most stubborn bugs occur<br />

because of program execution order. You may be setting something inside a movie clip that is<br />

being overridden by another clip or a root level loop. Often the best way <strong>to</strong> discover the error is <strong>to</strong><br />

trace every function call. The following code snippet from ‘Examples\Chapter11\debug13.fla’<br />

illustrates how <strong>to</strong> track program execution. Each function call is headed by a ‘trace’; the<br />

trace string is set <strong>to</strong> give the parameters passed <strong>to</strong> the function, which can often highlight an<br />

error.<br />

1 count = 0;<br />

2 while(count

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

Saved successfully!

Ooh no, something went wrong!