The process of developing an AIR application is much the same as that of developing an HTML-based web application.
The same thing is true when it comes to debugging an AIR application. One difference is that the JavaScript error messages go to the console (when running the application with AIR Debug Launcher) and not in a separate window as you might be used to in the browser world.
This section covers some of the new messages you might come across that are introduced by the runtime and also gives you a quick overview of an AIR SDK tool that can be used to make your life easier when working with HTML/JavaScript.
If you call code that is restricted from use in the application sandbox due to security restrictions, the runtime dispatches a JavaScript error: "Adobe AIR runtime security violation for JavaScript code in the application security sandbox."
When an object dispatches an event to a handler that has already been unloaded, you see the following error message: "The application attempted to reference a JavaScript object in an HTML page that is no longer loaded."
To avoid this error, remove JavaScript event listeners in an HTML page before it goes away. In the case of page navigation (within an HTMLLoader object), remove the event listener during the unload event of the window object.
// In this example the event listener for an uncaughtScript
Exception event is removed when unload event fires
window.onunload = cleanup;
window.htmlLoader.addEventListener('uncaughtScriptException',
uncaughtScriptException);
function cleanup()
{
window.htmlLoader.removeEventListener('uncaught
ScriptException',
uncaughtScriptExceptionHandler);
}
Exceptions, rather than events, are the primary mechanism for error handling in the runtime classes. However, because exceptions don't work for asynchronous operations, the runtime dispatches an error event object.
If you do not create a listener for the error event (such as when loading files asynchronously), the AIR Debug Launcher presents a dialog box with information about the error.
Most error events are based on the ErrorEvent class, and have a property named text that is used to store a descriptive error message.
An error event does not cause an application to stop executing. It manifests only as a dialog box when launched via ADL and is not presented when running in an installed application.
The Adobe AIR SDK includes a JavaScript based tool called AIR Introspector that makes it easier to develop HTML based applications for Adobe AIR. Tje tool can be used to introspect the content (such as the DOM) of HTML content running within an AIR application.

In order to use the AIR Introspector with your application, copy the AIRIntrospector.js file from the frameworks directory of the SDK into to your application project directory and then load the file into your application via the script tag:
<script src="airintrospector.js" type="text/javascript"> </script>
The tool provides a number of features and functionality:
A tool that allows you to point to a user interface element in the application and see its markup and DOM properties.
Ability to edit the attributes and text nodes for DOM elements.
A console for introspecting, and adjusting objects references, properties and code. This includes the ability to execute JavaScript code.
Lists of links, CSS styles, images, and JavaScript files loaded into the application.
Ability to view the initial HTML source and the current markup source for the user interface.
A viewer for XMLHttpRequest objects and their properties, including responseText and responseXML properties (when available).
Ability to search for matching text in the source code and files.
At this point, you should have a good understanding of the HTML and JavaScript environments within Adobe AIR, as well as how to leverage AIR, Flash Player and third-party ActionScript 3 APIs directly from JavaScript.
The rest of the book will use this knowledge to show how to accomplish specific tasks from HTML and JavaScript applications running within Adobe AIR.