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″?>
<s:ViewNavigatorApplicationxmlns:fx=”http://ns.adobe.com/mxml/2009″
xmlns:s=”library://ns.adobe.com/flex/spark”
firstView=”views.HelloWorldHomeView”
creationComplete=”viewnavigatorapplication1_creationCompleteHandler(event)”>
<fx:Script>
<![CDATA[
importmx.events.FlexEvent;
protectedfunction viewnavigatorapplication1_creationCompleteHandler
(event:FlexEvent):void
{
// TODO Auto-generated method stub
trace(“hello world”);
}
]]>
</fx:Script>
<fx:Declarations>
<!– Place non-visual elements (e.g., services, value objects) here –>
</fx:Declarations>
</s:ViewNavigatorApplication>
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.
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.