Debug a Flex Mobile Project


Now that you have created your Hello World application and ran it using the Run Configurations window, you may wish to debug your application. Fortunately for you, the workflow for debugging a Flex Mobile application is the same as debugging any other Adobe Flex or Adobe AIR application.

Update the HelloWorld.mxml file to include a creationComplete handler as shown here:

<?xml version=”1.0″ encoding=”utf-8″?>
protectedfunction viewnavigatorapplication1_creationCompleteHandler
// TODO Auto-generated method stub
trace(“hello world”);
<!– Place non-visual elements (e.g., services, value objects) here –>

We now need to toggle a breakpoint within the application on line 14, to demonstrate a debugging session. To do this, right-click on line 14 within Flash Builder and select Toggle Breakpoint from the context menu. Figure 1-11 shows this process. A small blue dot will appear in the gutter, showing that the break point is enabled.

We are now ready to debug this application. To do this, right-click on the Hello- World.mxml file within Package Explorer and select Debug As→Mobile Application, as shown in Figure 1-12. Since this is our first time debugging this application, the Debug Configurations window will open. To debug this using the Flash builder emulator, select “On desktop” as the Launch method and select a device from the drop-down menu, as shown in Figure 1-13.

Toggling a breakpoint

Debugging an application on a mobile device

The Debug Configurations window

When asked if you would like to switch to the Flash Builder debug perspective, select “Yes” (see Figure 1-14). Figure 1-15 shows the application paused on line 14 within Flash Builder’s debug perspective. You can see the trace message within the console panel. To allow the application to complete, click the Resume button.

Congratulations: you have just completed your first Flash Builder debug session for a Flex Mobile application.

Confirming the switch to debug perspective

The Hello World application paused on line 14