Debugging Your Code Flash

As you start to program your Flash movies with the latest and greatest ActionScript, you’ll likely encounter more than one error or experience frustration something you’ve written isn’t working as it should. You can track down errors in your code in three different ways:

  • Debugger Panel: Flash 5 has added a new comprehensive dedicated debugging tool to the authoring environment. The Debugger Panel can be activated in two ways:
    • Debug Movie command: Accessed with the Control➪Debug Movie command, this method of testing .SWF files enables the Debugger Panel.
    • Remote Debugging: You can now debug Flash movies from the Flash Player plug-in (or ActiveX Control), as the Flash movie plays in a Web browser window. You’ll need to take some steps to enable this feature, though. We discuss the Debugger Panel in more detail shortly.
  • Output window: The Output window will automatically open upon using the Test Movie (or Debug Movie) command when a trace action occurs (see the description later in this list) or when a syntax error is detected in the ActionScript. Syntax errors will appear in the Output window as soon as the export process for the .SWF file is completed. You can also manually update the Output window with useful moving information by using the List Objects and List Variables commands:
    • List Objects. While in Test Movie (or Debug Movie) mode, use Debug➪ List Objects to obtain a list of every element currently present on the movie stage, including Movie Clip instances, buttons, graphics, shapes, and text. List Objects displays the full names and paths of any Movie Clip instance or loaded movies. Useful for checking target names.
    • List Variables. While in Test Movie (or Debug Movie) mode, use Debug➪ List Variables to obtain a list of all variables currently initialized, and to find out their locations and values. This is very useful for checking whether a variable is resident at specific points on the movie timeline and for checking the name of the timeline upon which the variable resides.
    • trace(expression). Add a trace action to send a string or the value of an interpreted expression to the Output Window during Test Movie (or Debug Movie) mode. The value is sent when the trace action occurs. As a debugging tool, trace is analogous to alert() in JavaScript.
  • Custom debugging interfaces: You can also create your own debugging windows within a Flash movie, using draggable Movie Clips. Usually, Flash programmers will employ a temporary text field variable to display code output during development. Put temporary text fields on their own layer and make that layer a Guide Layer when exporting the production version of your movie.

Using the Debugger Panel
When you use the Control➪Debug Movie command, Flash 5 will create a .SWF file from your .FLA movie file, and open the Debugger Panel. The Debugger Panel (see Figure below) provides useful information about your .SWF file as it plays:

When it comes to tracking down scripting problems, the Debugger Panel is a welcome addition to Flash 5. The elements of the Debugger Panel are as follows:

When it comes to tracking down scripting problems, the Debugger Panel is a welcome addition to Flash 5. The elements of the Debugger Panel are as follows

  • Status Bar: Located at the top of the Debugger Panel, the Status Bar indicates where the .SWF file resides. If you used the Test Movie (or Debug Movie) command within Flash 5, then the Status Bar will read Test Movie. If you are debugging a .SWF file from a Web browser, then the Status Bar will show the full path (or URL) to the .SWF file.
  • Display List: The top pane of the Debugger Panel lists the absolute path (and nesting of) all of the current playing timelines for the Flash movie, including all native Movie Clip instances, all loaded .SWF files (in Levels or Movie Clip targets), and all duplicated or attached Movie Clips (created with ActionScript).
  • Properties tab: This first tab in the lower-left portion of the Debugger Panel lets you view all properties of a selected timeline in the Display List. You can even alter the values of the properties with string, numeric, or Boolean values. You cannot enter expressions (for example, x + 50) as a value of any property.
  • Variables tab: This middle tab in the lower portion of the panel enables you to view the variables on a selected timeline in the Display List. As with properties in the Properties tab, you can alter the values of any variable (with the same data type restrictions).
  • Watch tab: This right tab in the lower portion of the panel enables you to monitor specific variables on any timeline. You can add variables to the Watch list in one of two ways:
    1. By right-clicking (or Ctrl+clicking on the Mac) the variable name in the Variables tab and choosing Watch from the contextual menu
    2. By right-clicking (or Ctrl+clicking on the Mac) the empty area of the Watch list and choosing Add from the contextual menu.
    3. You can remove variables from the Watch list by right-clicking (or Ctrl+clicking on the Mac) the watched variable, and choosing Remove from the contextual menu.

Enabling remote debugging
As mentioned previously, you can now debug your Flash 5 .SWF files (served over the Web or from your local disk) as they play live in a Web browser. To enable debugging from a Web browser, you need to do two things:

  1. Allow debugging in the Publish Settings. Open the Publish Settings dialog (File➪Publish Settings), and select the Flash tab. Check the Debugging Permitted option, and enter a password if you are uploading the .SWF file to a live Web server. You do not need to supply a password, but we highly recommend it for security purposes.
  2. Install the Flash Player (Debug Version) for your preferred Web browser(s).

You will find the plug-in installer (or ActiveX Control installer) inside the Debug folder of the Players folder, located in the Flash 5 application folder. Make sure you delete any previously installed plug-ins or ActiveX Controls before attempting to install the Debug Player.

After you have enabled debugging and installed the Debug Player, you can point your browser to the .SWF’s location on the Web (or on your local disk). Alternatively, you can use the Publish Preview command (File➪Publish Preview➪HTML) to load the .SWF file (and supporting HTML file) into your preferred Web browser. After the movie has loaded into the browser, right-click (or Ctrl+click on the Mac), the movie’s Stage and select Debugger from the contextual menu. Focus will go back to the Flash 5 application, and you will be prompted to enter the debugging password as you supplied it in the Flash format tab of the Publish Settings dialog. If you left the password field blank, then simply click OK. Flash will open the Debugger Panel, providing you instant access to your movie’s timeline information, properties, and variables!

Make sure that you disable debugging (or use a password-protected debugger) before you launch your Flash movies on your live Web server. Otherwise, other people can debug your Flash movie.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

Flash Topics