Modifying Webkit’s Window Object in Adobe Air

When most developers discuss the possibilities available with Adobe Air, they typically talk about moving from the web to desktop. While there is plenty of thing to be excited about there, today I'm going to discuss the possibility of using Adobe Air to extend the power the web. Specifically, I want to show you how to modify the global window object in Webkit (the HTML renderer in Air) so that you can add your own custom properties and method for use within your web applications.
Today's example is how to create your own Ajax request cache to allow web applications to be run offline.
To kick this off, download the project files and use them to create your own FlexBuilder project.

Open up the main application mxml document and you'll see the following section minus the excessive inline comments:

//this bool would be toggled by the network status of the Air application

privatevar online:Boolean = true;

//called when the application first initializes

privatefunction init():void

{

// store a copy of the original XMLHttpRequest::open method

// all built-in objects are properties of the domWindow object available in an mx:Html view