The html-wrapper Flex Ant task generates files that you deploy with your Flex applications. In its simplest form, an HTML wrapper consists of an <object> and an <embed> tag that embed the SWF file in an HTML page.
The html-wrapper task outputs the index.html and AC_OETags.js files for your Flex application. If you enable deep linking support, the html-wrapper task also outputs the deep linking files such as historyFrame.html, history.css, and history.js. If you enable express installation, the html-wrapper task also outputs the playerProductInstall.swf file.
You typically deploy these files, along with your application's SWF file, to a web server. Users request the HTML wrapper, which embeds the SWF file. You can customize the output of the wrapper and its supporting files after it is generated by Ant.
For more information on the HTML wrapper, see Creating a Wrapper.
There are six types of HTML wrapper templates that you can generate with the html-wrapper Flex Ant task:
You determine which template is used by using a combination of the history and template attributes of the html-wrapper task.
The attributes of the html-wrapper task correspond to some of the attributes and parameters of the <object> and <embed> tags in the HTML wrapper. The task also supports some attributes that specify the output location and the type of wrapper to generate. For a complete list of the attributes and parameters of the <object> and <embed> tags in the HTML wrapper, see About the object and embed tags.
The following table describes the supported attributes of the html-wrapper task:
|
Attribute |
Description |
|---|---|
| application |
The name of the SWF object in the HTML wrapper. You use this name to refer to the SWF object in JavaScript or when using the ExternalInterface API. This value should not contain any spaces or special characters. This attribute sets the value of the <embed> tag's name attribute and the <object> tag's id attribute. |
| bgcolor |
Specifies the background color of the application. Use this property to override the background color setting specified in the SWF file. This property does not affect the background color of the HTML page. This attribute sets the value of the <embed> tag's bgcolor attribute and the <object> tag's bgcolor parameter. The default value is white. |
| file |
Sets the file name of the HTML output file. The default value is "index.html". |
| height |
Defines the height, in pixels, of the SWF file. Adobe® Flash® Player makes a best guess to determine the height of the application if none is provided. This attribute sets the value of the <embed> tag's height attribute and the <object> tag's height attribute. The default value is 400. |
| history |
Set to true to include deep linking support (also referred to as history management) in the HTML wrapper. Set to false to exclude deep linking from the wrapper. Use this attribute in combination with the template attribute to determine which template is used. The default value is false. For more information on deep linking, see Deep Linking in Adobe Flex 3 Developer Guide. |
| output |
Sets the directory that Ant writes the generated files to. |
| swf |
Sets the name of the SWF file that the HTML wrapper embeds (for example, Main). Do not include the *.swf extension; the extension is appended to the name for you. This attribute sets the value of the <embed> tag's src attribute and the <object> tag's movie parameter. This SWF file does not have to exist when you generate the HTML wrapper. It is used by the <object> and <embed> tags to point to the location of the SWF file at deployment time. |
| template |
The type of template to output. The value of this attribute must be one of the following:
Use this attribute in combination with the history attribute to determine which template is used. The default value is express-installation. |
| title |
Sets the value of the <title> tag in the head of the HTML page. The default value is Flex Application. |
| version-major |
Sets the value of the requiredMajorVersion global JavaScript variable in the HTML wrapper. The default value is 9. The value of this attribute only matters if you include version detection in your wrapper by setting the template attribute to express-installation or client-side-detection. |
| version-minor |
Sets the value of the requiredMinorVersion global JavaScript variable in the HTML wrapper. The default value is 0. The value of this attribute only matters if you include version detection in your wrapper by setting the template attribute to express-installation or client-side-detection. |
| version-revision |
Sets the value of the requiredRevision global JavaScript variable in the HTML wrapper. The default value is 0. The value of this attribute only matters if you include version detection in your wrapper by setting the template attribute to express-installation or client-side-detection. |
| width |
Defines the width, in pixels, of the SWF file. Flash Player makes a best guess to determine the width of the application if none is provided. This attribute sets the value of the <embed> tag's width attribute and the <object> tag's width attribute. The default value is 400. |
The html-wrapper task requires the swf attribute. In addition, if you specify only the swf attribute, the default wrapper will have the following default settings:
height="400" width="400" template="express-installation" bgcolor="white" history="false" title="Flex Application"
Be sure to use only the filename and not the filename and extension when specifying the value of the swf attribute. The html-wrapper task appends .swf to the end of its value.
For example, do this:
swf="Main"
Do not do this:
swf="Main.swf"
You cannot set all the available <object> and <embed> tag parameters using the html-wrapper task. Parameters you cannot set include quality, allowScriptAccess, classid, pluginspage, and type.
The following example project includes a wrapper target that uses the html-wrapper task to generate a wrapper with deep linking and player detection logic. This target also sets the height and width of the SWF file. The project also includes a clean target that deletes all the files generated by the wrapper target.
<?xml version="1.0" encoding="utf-8"?>
<!-- myWrapperBuild.xml -->
<project name="My Wrapper Builder" basedir=".">
<taskdef resource="flexTasks.tasks" classpath="${basedir}/lib/flexTasks.jar"/>
<property name="FLEX_HOME" value="C:/flex3/sdk"/>
<property name="APP_ROOT" value="apps"/>
<target name="wrapper">
<html-wrapper
title="Welcome to My Flex App"
file="index.html"
height="300"
width="400"
bgcolor="red"
application="app"
swf="Main"
version-major="9"
version-minor="0"
version-revision="0"
history="true"
template="express-installation"
output="${APP_ROOT}"/>
</target>
<target name="clean">
<delete>
<!-- Deletes playerProductInstall.swf -->
<fileset dir="${APP_ROOT}"
includes="playerProductInstall.swf"
defaultexcludes="false"/>
<!-- Deletes index.html and historyFrame.html -->
<fileset dir="${APP_ROOT}" includes="*.html" defaultexcludes="false"/>
<!-- Deletes history.css -->
<fileset dir="${APP_ROOT}" includes="*.css" defaultexcludes="false"/>
<!-- Deletes history.js and AC_OETags.js -->
<fileset dir="${APP_ROOT}" includes="*.js" defaultexcludes="false"/>
</delete>
</target>
</project>