Knowing the Flash Debugger Panel


ActionScript has evolved as a language with each release of Macromedia Flash. Indeed, if you're only starting to use Flash and ActionScript, it can seem quite overwhelming. Because there's so much you do with ActionScript, Macromedia has included a Debugger panel (see Figure 32-7), which has been available since the release of Flash 5.

image from book
Figure 32-7: The Debugger panel, showing all buttons and element names

The Debugger panel enables you to find errors in your code while your movie is playing in the Flash Player. As well as debugging local movies in Test Mode, you can also debug 9remote Flash movies that reside on a server. The Debugger panel can be a valuable tool when you are testing your movie and solving problems.

To Activate the Debugger and test your movie, choose Control Debug Movie. You must push the Continue button in the Debugger panel before your movie will start playing.

Displaying and Modifying Variables

While you are testing, you can use the Debugger panel to view or modify all variables in your movie. This is very useful because you will see the results of any change in a variable's value straightaway, as your movie is running.

Displaying a Variable

Follow these simple steps to view variables in the Debugger that exists in your movie:

On the CD-ROM 

You can find debugging_code.fla in the ch32 folder on this book's CD-ROM. Copy this file to a location on your hard drive. We will use it in the next few examples.

  1. Choose File Open and browse to the folder on your hard drive where you have saved debugging_code.fla. Highlight it and select OK.

  2. Enter Debug mode by choosing Control Debug Movie.

  3. Select Continue (that is, the play button in the toolbar of the panel) to start the movie playing.

  4. Select the Variables tab. This is where all of the variables are displayed.

  5. Select the _level0.mcTest Movie Clip from the Display list to see the variables that exist in that timeline.

  6. Select the _level0 target to see the variables change in the Variables tab.

Note 

Because there is a breakpoint added to the actions on frame 2, you need to press the Continue button each time the breakpoint is encountered during playback. Breakpoints are discussed later in this chapter.

Modifying a Variable

Follow these simple steps to modify variables in the Debugger panel that exist in your movie:

  1. Open the debugging_code.fla document.

  2. Enter Debug mode by choosing Control Debug Movie.

  3. Select Continue to start the movie playing.

  4. Select the _level0 target from the Display list.

  5. Select the Variables tab.

  6. Double-click on the Value field for the nCount variable and enter 70 as its new value. When you click the Continue button, you will see how the value of the nCount variable increases to 70 and increments from there.

Tip 

All objects, either user defined or predefined ActionScript objects, will appear in the variable list. However, you can only change the values of some properties and variables.

The Watch List

Using the Debugger panel to monitor the value of multiple variables can get quite confusing, especially if you need to compare variables that exist on different timelines. Employing the Watch list is an easy way to monitor the value of certain variables in a manageable way.

Once you have added a variable to the Watch list, you can view it regardless of which Movie Clip you have selected in the Movie Clip list.

Adding a Variable to the Watch List

There are two options for adding a variable to the Watch list.

  1. Open the debugging_code.fla document.

  2. Start a debugging session by choosing Control Debug Movie.

  3. Select Continue to start the movie playing.

  4. Select the _level0 target from the Display list.

  5. Select the Variables tab to show all variables from the _level0 namespace.

  6. Right-click (Windows) or Control-click (Mac) on the nCount variable and select Watch. A little blue dot appears indicating that it is in the Watch list.

  7. Select the Watch tab to view the Watch list. You will see the nCount variable and its value change as you progress through the debugging session.

Alternatively, you can perform the following steps to add a watch to the Flash movie.

  1. Repeat Steps 1 and 2 from the previous method.

  2. Select the Watch tab.

  3. From the Debugger panel's options menu, choose Add Watch. Alternatively, you can right-click (Windows) or Control+click (Mac) the empty area of the Watch tab and choose Add.

  4. Double-click the new entry (<undefined>) in the Named column and type in the correct path and name of the variable you want to watch.

Caution 

If you type in an incorrect path or variable name, the variable value will be undefined in the Watch list.

Removing a Variable from the Watch List

There are three methods to remove a variable from the Watch list. The first method involves the following steps:

  1. Navigate to the variable using the Display list and the Variables tab.

  2. Right-click (Windows) or Control+click (Mac) the variable you wish to remove and deselect the Watch command. The little blue dot will be removed.

The second method involves these steps:

  1. Select the Watch tab.

  2. In the Watch list, right-click (Windows) or Control+click (Mac) on the desired variable and select Remove.

Alternatively, the third method involves these steps:

  1. Select the Watch tab.

  2. Highlight the variable you no longer need and select Remove Watch from the Debugger options menu.

Editing and Displaying Movie Properties

The Properties tab of the Debugger panel displays the properties of all the Movie Clip instances, including the Main Timeline (_root, displayed as _level0) in your movie. Follow these steps to view and edit movie properties while debugging.

Perform these steps to view the properties of any Movie Clip timeline in the movie:

  1. Open a file that you want to debug.

  2. Enter Debug Mode by choosing Control Debug Movie. In the Debugger panel, click Continue.

  3. Select a Movie Clip instance from the Display list. Choose something other than _global.

  4. Select the Properties tab to view the properties of the selected Movie Clip instance. The properties that appear in a different color from the majority of the properties are read-only and cannot be changed.

Tip 

For processor intensive applications in Flash 8 that use the drawing API, try changing the _quality property of the _level0 timeline to "LOW" to see increased performance.

Perform these steps to edit a specific property of a timeline or object in the Debugger panel:

  1. Follow Steps 1 through 3 of the previous exercise.

  2. Double-click the Value field of the property you wish to alter and enter the new value.

Note 

If you enter an incorrect value, such as a string when a number is required, the Debugger panel ignores the change, reversing the value to its last valid state the next time you reselect that Movie Clip instance.




Macromedia Flash 8 Bible
Macromedia Flash8 Bible
ISBN: 0471746762
EAN: 2147483647
Year: 2006
Pages: 395

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net