« on AIR Bus Tour Boston: Introduction to Adobe AIR with Flex | Main | on AIR Bus Tour Boston: ActionScript and JavaScript Integration »

on AIR Bus Tour Boston: Building AIR with HTML and JavaScript

Kevin Hoyt gave a talk about how to use the AIR SDK to develop an AIR application using HTML and JavaScript.

The AIR SDK includes:
adl: Launcher for AIR applications
adt: Packager for AIR applications

AIR Aliases: shortcuts for HTML development
Service Monitor: ability to detect if you are online or offline

Application descriptor template, code samples, and badge packager and source are also included. Currently 4 clicks to install and launch an application from a website using the badge process.

HTML Main Application:
He created a standard HTML file and saved it as index.html (not a requirement to be named index.html).

From a terminal running the adl command with -help will give you information on the command line syntax. Besides launching your application, adl can also pass command line arguments into your application.

He created an application descriptor from the template. Import difference from the Flex example was to set the rootContent to index.html. Descriptor also supports fileTypes which lets you associate a file extension with your application.

WebKit will include CSS3 support.

DreamWeaver has extensions that suppy AIR capabilities. Can launch applications and edit descriptors from within DreamWeaver.

He added an HTML text form field and button. Created an event listener which is registered as part of a body onLoad function. The first version of the event listener function popped up an alert to test that everything was working. Next he pulled the text form value out and saved it to disk.

In JavaScript, the rough code is:

var file = window.runtime.flash.filesystem.File.desktopDirectory.resolve('boston.txt');

// If you include AIRAliases.js this can be shortened to
var file = air.File.desktopDirectory.resolve('boston.txt');

// Now that we have a file reference:
var stream = new air.FileStream();
stream.open(file, air.FileMode.WRITE);
stream.writeMultiByte("text", air.File.systemCharset);

The AIR API also has support to read and write in an asynchronous mode using events.

Aptana: Open Source Eclipse IDE for JavaScript/HTML development and debugging. Includes built in support to run and package AIR applications. Best part is the sample applications that come bundled with it. Meebo directory includes custom HTML chrome application example.

Tags: air html javascript onair2007boston