Embedding SWF content in HTML

You can embed SWF content in HTML content within an AIR application just as you would in a browser. Embed the SWF content using an object tag, an embed tag, or both.

Note: A common web development practice is to use both an object tag and an embed tag to display SWF content in an HTML page. This practice has no benefit in AIR. You can use the W3C-standard object tag by itself in content to be displayed in AIR. At the same time, you can continue to use the object and embed tags together, if necessary, for HTML content that is also displayed in a browser.

The following example illustrates the use of the HTML object tag to display a SWF file within HTML content. The SWF file is loaded from the application directory, but you can use any of the URL schemes supported by AIR. (The location from which the SWF file is loaded determines the security sandbox in which AIR places the content.)

<object type="application/x-shockwave-flash" width="100%" height="100%"> 
    <param name="movie" value="app:/SWFFile.swf"></param> 

You can also use a script to load content dynamically. The following example creates an object node to display the SWF file specified in the urlString parameter. The example adds the node as a child of the page element with the ID specified by the elementID parameter:

function showSWF(urlString, elementID){ 
    var displayContainer = document.getElementById(elementID); 
function createSWFObject(urlString, width, height){ 
    var SWFObject = document.createElement("object"); 
    var movieParam = document.createElement("param"); 
    return SWFObject;