1. 安装ant,然后复制FLEX_HOME/sdks/4.0.0/ant/lib下面的flexTasks.jar到ANT_HOME/lib
2. build.properties
# change this to your Flex SDK directory path
FLEX_HOME=D:/Adobe/Adobe Flash Builder 4 Plug-in/sdks/4.0.0
# this points to your project's src directory
# {$basedir} is a default variable that can be used in any Ant
script
# and it points to the project's root folder [ flex_ant_pt1_Tasks ]
in this case
SRC_DIR =${basedir}/src
# points to the project's libs directory
LIBS_DIR =${basedir}/libs
# this is the folder we want to publish the swf to
DEPLOY_DIR = ${basedir}/DEPLOY
3. build.xml
<project name="Flex Ant Tasks Build Script" default="compile flex project">
<!-- load previously defined configuration properties file -->
<property file="build.properties" />
<!-- points to our flexTasks.jar we copied to the libs folder to distribute with the project -->
<taskdef resource="flexTasks.tasks" classpath="${basedir}/libs/flexTasks.jar"/>
<!-- delete and create the DEPLOY dir again -->
<target name="init">
<delete dir="${DEPLOY_DIR}" />
<mkdir dir="${DEPLOY_DIR}" />
</target>
<!-- Build and output the Main.swf-->
<target name="compile flex project" depends="init">
<mxmlc file="${SRC_DIR}/Main.mxml" output="${DEPLOY_DIR}/Main.swf">
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<source-path path-element="${FLEX_HOME}/frameworks"/>
<compiler.debug>false</compiler.debug>
</mxmlc>
</target>
</project>
4. 在Flex Builder中创建一个Flex项目,新建一个Main.mxml
5.cmd进入到刚才创建的Flex项目目录,执行ant命令。注意:build.properties,build.xml放在刚才创建的Flex项目根目录下