Chapter 12. Debugging Debugged
When you write code, you can expect problems to creep in. No matter how hard you try, there is always something that just doesn't work. Fortunately, strategies exist for reducing, finding, and fixing these bugs. This chapter brings you up to speed on the kinds of bugs you'll be facing.
Types of Bugs
Numerous types of bugs exist that, for the most part, fall into two categories: compile-time bugs and logic bugs. Compile-time bugs are problems that are detected by the compiler and usually involve code syntax or structure errors. Logic bugs involve code that successfully runs, but that does not operate the way that you intend. They are the bugs that you will be mostly concerned with, and that will require the most attention.
Compile-Time Bugs
Compile bugs are the easiest to deal with. As the Flash compiler creates an SWF file, it goes through all of your code and makes sure that it conforms to the required syntax. If any code is invalid, such as an opening brace not having a matching closing brace, or a for
statement that does not have the correct usage, it aborts the compile. Additionally, it lets you know where the error is and gives you a description of what is wrong.
The compiler also tests to make sure that all variable, function, and class usage conforms to the rules in their respective definitions. That means that if you declare a variable of type Boolean, and you assign it to a variable of type Number, the compiler will flag the mismatch. You'll also ...
Get Beginning ActionScript 2.0 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.