Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
By now, you should be aware that Flex applications get compiled to .swf files. When you deploy a Flex application to the Web, you must place the .swf file for the Flex application on the web server. At a minimum, this one file is always required. However, in almost all cases you will need to provide at least one additional file: an HTML file that embeds the .swf. Although it is possible for users to access an .swf file directly in a web browser, such an approach is inadvisable. Keep in mind that when users access a Flex application in a browser, you will still want the browser to display basic information such as a title, information that only an HTML page can provide. Furthermore, by using an HTML page, it is possible to do much more with a Flex application than if the user was accessing the application’s .swf file directly in the browser. For example, using an HTML page you can utilize JavaScript. And by embedding a Flex application in HTML, you can place the application alongside other non-Flex content. Not only that, but by using JavaScript and HTML, you can detect whether the user even has Flash Player installed. Therefore, embedding Flex applications in HTML is a fundamental skill for creating Flex applications. In the next few sections, we will look at various ways in which you can embed Flex content in HTML pages.
NOTE
Any technology that writes HTML to a browser can be used interchangeably with HTML files, as we describe in this chapter. For example, you can use the same principles described in this chapter with PHP, .NET, and Ruby to embed a Flex application.