Specifications

CHAPTER 9
190
Example
The following example compc task builds a new SWC file that contains two custom components and other assets.
The components are added to the SWC file by using the
include-classes attribute. The source files for the
components are in a subdirectory called components. The other assets, including four images and a CSS file, are
added to the SWC file by using the
include-file element. This example defines two targets: main and clean.
The main target compiles the MyComps.swc file. The clean target deletes the output of the main target.
<?xml version="1.0" encoding="utf-8"?>
<project name="My Component Builder" basedir=".">
<taskdef resource="flexTasks.tasks"
classpath="${basedir}/flexTasks/lib/flexTasks.jar" />
<property name="FLEX_HOME" value="C:/flex/sdk"/>
<property name="DEPLOY_DIR" value="c:/jrun4/servers/default/default-war"/>
<property name="COMPONENT_ROOT" value="components"/>
<target name="main">
<compc
output="${DEPLOY_DIR}/MyComps.swc"
include-classes="custom.MyButton custom.MyLabel">
<source-path path-element="${basedir}/components"/>
<include-file name="f1-1.jpg" path="assets/images/f1-1.jpg"/>
<include-file name="f1-2.jpg" path="assets/images/f1-2.jpg"/>
<include-file name="f1-3.jpg" path="assets/images/f1-3.jpg"/>
<include-file name="f1-4.jpg" path="assets/images/f1-4.jpg"/>
<include-file name="main.css" path="assets/css/main.css"/>
</compc>
</target>
<target name="clean">
<delete>
<fileset dir="${DEPLOY_DIR}" includes="MyComps.swc"/>
</delete>
</target>
</project>
Using the html-wrapper task
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.