
Adobe Flash Player and Adobe AIR provide the ability to run full-featured rich Internet applications (RIAs) either inside a web browser or as native desktop applications on both Windows and Mac OS X, with desktop Linux support coming sometime after the release of Adobe AIR 1.0. The problem for those who want to develop applications that support both desktop and web runtime environments is that Adobe AIR includes extra APIs that allow for local file access, SQLite database support, native windows, and more. These APIs won't compile into a traditional Flex web-based application destined for web-browser distribution (SWF files that you place on a web server and run inside the browser).
In this article, I'm going to show you a technique to set up your Flex Builder 3 workspace and organize your code to output both a Flex web and desktop Adobe AIR application from the same code base. This technique enables you to create a single maintainable code base that will give you web and Adobe AIR applications from your Flex Builder workspace. To demonstrate this, I will set up three projects: one for Adobe AIR, one for the web, and one for the common code. The web and desktop applications will then make calls against an interface that is defined in a common project, but has concrete implementations in each of the desktop and web projects, allowing the desktop version to use the new functionality of Adobe AIR, and giving the developer the option to support a different implementation for the web-based application.
With this knowledge, you'll be able to write software for both a rich browser experience and a desktop application from a code base that doesn't have a bunch of duplicate code. In doing this, you could offer both an online demo with crippled functionality and a desktop version of the application that can run offline with more advanced functionality.
In order to make the most of this article, you need the following software and files:
This article assumes intermediate to advanced knowledge of Flex, ActionScript 3.0, and MXML. You should know how to create Adobe AIR and Flex projects in Flex Builder 3, and be comfortable with a few object-oriented concepts such as inheritance and interfaces, as well as a splash of UML 2.0.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License