Skip To Content

Debugging tips

Version 3.7

Use the following tips, including Flex code and calls to the server, to debug your ArcGIS API for Flex application.

Checking the problem view

When compiling your application in Adobe Flash Builder, note the messages on the Problems tab located below your code.

Screenshot of the Problems tab in Adobe Flash Builder.

Using the trace() function

You can add trace calls to output comments with text and variables to the Console tab. Note that the trace() function only initiates when running in the debug mode.

Screenshot of the trace statement and Console tab

Using TraceTarget

Use TraceTarget as an alternative to multiple trace() calls. To use TraceTarget, add <mx:TraceTarget/> to your code, then debug the application in Flash Builder (press F11 or click the debug icon This is required). All network interactions will appear in the Console tab, allowing you to listen for traffic between your Flex application and a server. This is especially helpful when working with a server task (for example, the geoprocessing task).

See the Adobe site for more information on TraceTarget.

Using the debug version of Flash Player

Ensure you have the debug version of Flash Player installed. Right-click anywhere in a Flash application and verify that Show Redraw Regions and debugger appear in the list.

To debug your application, first set breakpoints in your code. The debugger will stop executing the application at those specific points, and you can then inspect variables and step through the code one line at a time.

You can also take advantage of the debug functionality in Adobe Flash Builder. Click the Debug button (to the right of the Run button) or press F11. When in debug mode, Flash Builder will append ?debug=true to the URL.

For more information, go to http://learn.adobe.com/wiki/display/Flex/3g.+Debug+your+applicationand follow the tutorial and video links.

Monitoring web traffic

If your application compiles but the maps and tasks are not working, use an HTTP monitoring tool to watch the interaction with ArcGIS Server tasks and services and other external requests. For instance, use the HttpFox extension in Firefox or a cross-browser monitoring tool such as Charles Web Debugging Proxy.

Note that all communication with ArcGIS Server uses the REST API, so there are many open-source solutions available to view requests (headers and parameters) and responses. This is especially helpful when working with tasks. For example, you can take the request from HttpFox or Charles and directly manipulate the variables in the browser.

When finished debugging, don't forget to close your debugging session by either closing the browser or pressing the Terminate button in the Console view.