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.

5 onClipEvent(enterFrame){<br />

6 count++;<br />

7 }<br />

Listing 11.6 ‘Examples/Chapter11/debug08.fla’<br />

Figure 11.2 Developing the debug08 project<br />

Chapter 11: Debugging<br />

If you try running the program, however, the number stays stubbornly at zero. Why? It is because<br />

the text box is tracking the variable ‘count’, rather than the variable ‘counter.count’. This very<br />

simple error is so common that you are advised <strong>to</strong> check for it as a first step in debugging your<br />

code. Always ensure that you are dealing with a variable that has the correct scope.<br />

Figure 11.3 Setting a variable for a dynamic text box<br />

157

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

Saved successfully!

Ooh no, something went wrong!