By now, you've got a handle on developing Flex applications for rich Internet applications (RIAs). You've also learned how the AIR runtime facilitates the creation of desktop applications. Now you might be thinking, how do I build an application from the same codebase targeting both the browser and the desktop? If so, this chapter is for you.
By its nature, AIR contains all the FLEX APIs, plus the AIR-specific APIs. Projects compiled for Web-based distribution don't include the AIR APIs, so if you try to compile an AIR project for the Web, you'll receive "Type was not found" compile errors. And if you're using Flex Builder, you won't even be able to import any of the AIR APIs because the
airframework.swc files aren't included as build path libraries for Flex projects targeting the Web.
This chapter will show two different methods of writing software for both the Web and desktop. The first method will use a design-by-interface approach, combined with multiple Flex Builder projects to create software that can be run inside the web browser as a Flex application or on the desktop with AIR. The second method is the use of the new Flex compiler directives, which will be more of a chainsaw approach to coding but won't require the upfront effort that the design-by-interface approach requires.
The first solution to create both AIR and Flex applications involves creating a few projects in Flex Builder. One project ...