Debugging a desktop AIR applicationIf you are developing your application with an IDE such as Flash Builder, Flash Professional, or Dreamweaver, debugging tools are normally built in. You can debug your application simply be launching it in debug mode. If you are not using an IDE that supports debugging directly, you can use the AIR Debug Launcher (ADL) and the Flash Debugger (FDB) to assist in debugging your application. Running an application with ADLYou can run an AIR application without packaging and installing it using ADL. Pass the application descriptor file to ADL as a parameter as shown in the following example (ActionScript code in the application must be compiled first): adl myApplication-app.xml ADL prints trace statements, runtime exceptions, and HTML parsing errors to the terminal window. If an FDB process is waiting for an incoming connection, ADL will connect to the debugger. Printing trace statementsTo print trace statements to the console used to run ADL, add trace statements to your code with the trace() function. ActionScript example: //ActionScript
trace("debug message");
JavaScript example: //JavaScript
air.trace("debug message");
In JavaScript code, you can use the alert() and confirm() functions
to display debugging messages from your application. In addition,
the line numbers for syntax errors as well as any uncaught JavaScript
exceptions are printed to the console.
Note: To use the air prefix
shown in the JavaScript example, you must import the AIRAliases.js
file into the page. This file is located inside the frameworks directory
of the AIR SDK.
Connecting to the Flash Debugger (FDB)To debug AIR applications with the Flash Debugger, start an FDB session and then launch your application using ADL. Note: In SWF-based AIR applications, the ActionScript source files
must be compiled with the -debug flag. (In Flash
Professional, check the Permit debugging option in the Publish Settings
dialog.)
If an AIR application is SWF-based, the debugger only controls the execution of ActionScript code. If the AIR application is HTML-based, then the debugger only controls the execution of JavaScript code. To run ADL without connecting to the debugger, include the -nodebug option: adl myApp.xml -nodebug For basic information on FDB commands, execute the help command: <fdb>help [Enter] For details on the FDB commands, see Using the command-line debugger commands in the Flex documentation. |
|