If 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.
You can also use ADL to debug an AIR application that uses native
extensions. For example:
adl -extdir extensionDirs myApplication-app.xml
Printing trace statementsTo print trace statements to the console used to run ADL,
add trace statements to your code with the trace() function.
Note: If your trace() statements do not display
on the console, ensure that you have not specified ErrorReportingEnable or
TraceOutputFileEnable in the mm.cfg file. For
more information on the platform-specific location of this file, see Editing the mm.cfg file.
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.)
Start FDB. The FDB program can be found in the bin directory
of the Flex SDK.
The console displays the FDB prompt: <fdb>
Execute the run command: <fdb>run [Enter]
In a different command or shell console, start a debug version
of your application:
adl myApp.xml
Using the FDB commands, set breakpoints as desired.
Type: continue [Enter]
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:
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.
|
|
|