Understanding How Flex Applications Work

Flex applications deployed on the Web work differently than HTML-based applications. It’s important to understand how Flex applications work in order to build them most effectively. When you understand how Flex applications work, you can know what elements are necessary for an application and how to build the application for the best user experience. Figure 1-1 summarizes the basic concepts discussed in this section.

Understanding Flex application source-compile-deploy workflow

Figure 1-1. Understanding Flex application source-compile-deploy workflow

Every Flex application deployed on the Web utilizes Flash Player as the deployment platform. That means a fundamental understanding of Flash Player is essential to understanding Flex. Additionally, all Flex applications use the Flex framework at a minimum to compile the application. As such, it’s important to understand the relationship between the source code files, the compiler, and Flash Player.

All Flex applications require at least one MXML file or ActionScript class file, and most Flex applications utilize both MXML and ActionScript files. The MXML and ActionScript class files comprise the source code files for the application. Flash Player does not know how to interpret MXML or uncompiled ActionScript class files. Instead, it is necessary to compile the source code files to the .swf format, which Flash Player can interpret. A typical Flex application compiles to just one .swf file. You then deploy that one .swf to the server, and when requested, it plays back in Flash Player. That means that unlike HTML-based applications, the source code files remain on the development machine, and you do not deploy them to the production server.

Asset files such as MP3s, CSS documents, and PNGs can be embedded within an .swf or they can be loaded at runtime. When an asset is embedded within an .swf, it's not necessary to deploy the file to the production server, since it is compiled within the .swf file. However, since embedding assets within the .swf often makes for a less streamlined downloading experience and a less dynamic application, it is far more common to load such assets at runtime. That means the asset files are not compiled into the .swf, and much like an HTML page the assets are loaded into Flash Player when requested by the .swf at runtime. In that case, the asset files must be deployed to a valid URL when the .swf is deployed.

Data services are requested at runtime. That means the services must be available at a valid URL when requested at runtime. For example, if a Flex application utilizes a web service, that web service must be accessible from the client when requested. Media servers and Flex Enterprise Services must also be accessible when utilized by Flex applications.

Get Programming Flex 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.