Chapter 19. Testing and Debugging Your Animation

The odds are against you. When you're designing an animation and writing ActionScript code, there may be several ways to do it and have it come out right. Unfortunately, there are many more ways you can do it wrong. Maybe you chose a motion tween when you meant to choose a shape tween, or you added content to a frame instead of a keyframe. In ActionScript, a tiny error like using a capital letter in the wrong place or misplaced semicolon can ruin everything. The more complex your project is, the more errors you're likely to encounter.

The only way to find—and fix—your mistakes before your audience sees them is to test and debug your projects. Yes, troubleshooting can be tedious, time-consuming, and not nearly as much fun as designing and creating a brilliant animation. But if you approach troubleshooting as solving a puzzle or a mystery, it can be fun. Furthermore, Flash Professional CS5 comes with some pretty powerful testing and debugging tools to you help you find and squash those bugs.

Throughout this book, you've seen examples of testing an animation using the Control→Test Movie option (for example, Figure 19-5). This chapter expands on that simple test option, plus it shows you how to test animation playback at a variety of connection speeds. And if you've added ActionScript to your animation, this chapter shows you how to unsnarl uncooperative ActionScript code using Flash's debugging tools.

All your audience ever sees is the finished product, not your intentions. So no matter how sophisticated your animation or how cleverly constructed your ActionScript code, if you don't test your animation and make sure it works the way you want it to, all your hard work will have been in vain.

The following section shows you how to prepare for testing from the very beginning by following good Flash development policies. Also, you'll find out the differences between testing on the stage and testing in Flash Player, along with tips for testing your animation in a web browser.

The more complex your animation, the more you need a thorough plan for testing it. Few of the guidelines in the next two sections are specific to testing in Flash. Instead, they're tried-and-true suggestions culled from all walks of programming life. Following them pays off in higher-quality animations and reduced time spent chasing bugs.

Ideally, you should begin thinking about testing before you've created a single frame of your animation. Here are some pre-animation strategies that pay off big:

The following strategies are crucial if you're creating complex animations as part of a development team. But they're also helpful if it's just you creating a short, simple animation all by your lonesome.