Adobe Flex 3 Help

Debugging your applications

Debugging is similar to running your applications. However, when you debug you control when the application stops at specific points in the code and whether you want it to monitor important variables, and you can test fixes to your code. Both running and debugging use a configuration to control how applications are launched. When you debug your application, you run the debug version of the application file.

For an overview of the debugging tools available in the Flex Debugging perspective, see The Flex Debugging perspective.

In some cases, you will be prompted to look at the Eclipse log file. For more information, see Eclipse environment errors in the log file.

Starting a debugging session

To begin a debugging session, you run the application launch configuration in the Flex Debugging perspective.

Debug an application

  1. In the Flex Navigator view, select the project to debug.
  2. Select the Debug button from the main workbench toolbar.

    Note: The Debug button has two elements: the main action button and a drop-down list that shows the application files in the project that can be run or debugged. When you click the main action button, the project's default application file is debugged. You can alternatively click the drop-down list and select any of the application files in the project to debug. You can also access the launch configuration dialog box and create or edit a launch configuration by selecting the Debug command.

    If your project has not been built yet, Flex Builder builds and runs it in debug mode.

  3. Your application appears in your default web browser or the stand-alone Flash Player and you can then use the Flex Builder debugger to interact with it.
  4. When a breakpoint is reached, the Flex Debugging perspective is activated in the workbench.

Start a debugging session in the plug-in configuration

The Debug command works differently in the plug-in configuration of Flex Builder. Instead of running the selected project, it debugs the most recently launched configuration. You can also select from a list of recently launched configurations.

Adding and removing breakpoints

You use breakpoints to suspend the execution of your application so you can inspect your code and use the Flex Builder debugging tools to explore options to fix errors. You add breakpoints in the code editor and then manage them in the Breakpoints view when you debug your applications.

You add breakpoints to executable lines of code. The debugger stops only at breakpoints set on lines that contain the following:

  • MXML tags that contain an ActionScript event handler, such as
    <mx:Button click="dofunction()" ...>
  • ActionScript lines such as those enclosed in an <mx:Script> tag or in an ActionScript file
  • Any executable line of code in an ActionScript file

You can set breakpoints as you write code or while you debug.

Set a breakpoint in the code editor

  1. Open a project file that contains ActionScript code.
  2. Locate the line of code on which you want to set a breakpoint, and double-click in the marker bar to add a breakpoint.

    The marker bar is along the left edge of the code editor.

    A breakpoint marker is added to the marker bar and to the list of breakpoints in the Breakpoints view of the Flex Debugging perspective.

    When the debugger encounters a breakpoint, the application is suspended, the Flex Debugging perspective is displayed, and the line of code is marked with a breakpoint that is highlighted in the code editor. You then use the debugging commands to interact with the code. (See Managing the debugging session in the Debug view).

Remove a breakpoint in the code editor

 In the marker bar, double-click an existing breakpoint.

The breakpoint is removed from the marker bar and the Breakpoints view of the Flex Debugging perspective.

You manage breakpoints in the Breakpoints view. You can remove one or all breakpoints in the list or disable them and re-enable them at a later time (see Managing breakpoints in the Breakpoints view).

Managing breakpoints in the Breakpoints view

In the Breakpoints view you manage breakpoints during a debugging session. You can remove, disable and enable, or skip them.

The following commands are available from the Breakpoints view toolbar (as shown left to right):

Breakpoints view toolbar

Button/Command

Description

Remove Selected Breakpoints

Removes the selected breakpoints.

Remove All Breakpoints

Removes all breakpoints.

Show Breakpoints Supported by Selected Target

Displays breakpoints that are applicable to the select debug target.

Go to File for Breakpoint

Opens the file (if it is not already open) that contains the breakpoint in the code editor and highlights the line of code on which the breakpoint was set. You can also simply double-click the breakpoint to display it in the code editor.

Skip All Breakpoints

Skips all breakpoints.

Expand All

Expands all breakpoints.

Collapse All

Collapses all breakpoints.

Link With Debug View

Links to Debug view.

Remove breakpoints in the Breakpoints view

You can remove one, a few, or all of the breakpoints in the Breakpoints view from the Breakpoints toolbar

 Select one or more breakpoints from the list of breakpoints, and then click Remove Selected Breakpoints.

You can also remove all the breakpoints in the Breakpoints view in a single action.

Remove all breakpoints from the Breakpoints view

 In the Breakpoints view, click Remove All Breakpoints.

Managing the debugging session in the Debug view

The Debug view is the control center of the Flex Debugging perspective. You use it to control the execution of the application, to suspend, resume, or terminate the application, or to step into or over code.

The Debug view provides the following debugging commands, which are available from the Debug view toolbar (as shown left to right):

Debug view toolbar

Button/Command

Description

Remove All Terminated Launches

Clears all terminated debugging sessions.

Resume

Resumes the suspended application.

Suspend

Suspends the application so that you can inspect, step into the code, and so on.

Terminate

Terminates the debugging session.

Disconnect

Disconnects the debugger when debugging remotely.

Step Into

Steps into the called function and stops at the first line of the function.

Step Over

Executes the current line of the function and then stops at the next line of the function.

Step Return

Continues execution until the current function has returned to its caller.

Drop to Frame

This command is not supported in Flex Builder.

Use Step Filters

This command is not supported in Flex Builder.

Using the Console view

The Console view displays the output from trace statements placed in your ActionScript code and also feedback from the debugger itself (status, warnings, errors, and so on).

The Console view provides the following commands, which are available from the Console view toolbar (as shown left to right):

Console view toolbar

Button/Command

Description

Terminate

Terminates the debugging session.

Remove Launch

Clears all launched debugging sessions.

Remove All Terminated Launches

Clears all terminated debugging sessions.

Clear Console

Clears all content from the Console view.

Scroll Lock

Prevents the Console view from scrolling.

Show Console When Standard Out Changes

 

Show Console When Standard Error Changes

 

Pin Console

Prevents the console from refreshing its contents when another process is selected.

Display Selected Console

 

Open Console

Opens new console and displays pop-up menu to select other console views.

Managing variables in the Variables view

The Variables view displays the variables that the currently selected stack frame defines (in the Debug view). Simple variables (name and value) are displayed on a single line. Complex variables can be expanded to display their members. You use the Variables view to watch variables by adding them to the Expressions view and to modify the value of variables during the debugging session.

All superclass members are grouped in a separate tree node; by default you see only the members of the current class. This helps reduce excess numbers of variables that are visible at one time in Variables view.

The Variables view provides the following actions, which are available from the Variables view toolbar (as shown left to right):

Command

Description

Show Type Names

Displays the type names of variables.

Show Logical Structure

This command is not supported in Flex Builder.

Collapse All

Collapses the Variables view.

Change the value of a variable

  1. Select the variable to modify.
  2. Right-click (Control-click on Macintosh) to display the context menu and select Change Value.
  3. Enter the new value and click OK.

    The variable contains the new value.

Modified variables are displayed in red.

Find variables

 To locate a variable or variable member in the Variables view, with the Variables view selected, begin entering the name of the variable you're looking for. You can also use the wildcard character (*) to search for words that occur anywhere within a variable name (for example, "*color").

Using the Expressions view

You use the Expressions view to watch variables you selected in the Variables view and to add and evaluate watch expressions while debugging your applications.

While debugging, you can inspect and modify the value of the variables that you selected to watch. You can also add watch expressions, which are code expressions that are evaluated whenever debugging is suspended. Watch expressions are useful for watching variables that may go out of scope when you step into a different function and are therefore not visible in the view.

The Expressions view provides the following commands, which are available from the Variables view toolbar (as shown left to right):

Expressions view toolbar

Command

Description

Show Type Names

Shows the object types for items in the Expressions view.

Show Logical Structure

This command is not supported in Flex Builder.

Collapse All

Collapses all expressions in view.

Remove Selected Expressions

Removes the selected variable or watch expression.

Remove All Expressions

Removes all variables and watch expressions from the Expressions view.

You can also hover the mouse pointer over an expression or variable in the source editor to see the value of that expression or variable as a tooltip. You can add the expression to the Expressions view by right-clicking and selecting Watch from the menu.