1.首先安装flex插件Adobe Flex Builder 3.2.0 Professional Eclipse Plug-in。
2.然后将Flex Builder3 Plug-in/sdks/3.2.0/ant/lib下的flexTasks.jar 复制到 ant的apache-ant-1.7.1/lib下。
3.配置ant下的build.xml文件,脚本如下:
//设定引用的资源
<taskdef resource="flexTasks.tasks"
classpath="C:/Adobe/Flex Builder 3 Plug-in/sdks/3.2.0/ant/lib/flexTasks.jar"/>
//定义路径属性
<property name="FLEX_HOME" value="C:/Adobe/Flex Builder 3 Plug-in/sdks/3.2.0"/>
<property name="APP_ROOT" value="${basedir}/flex_src"/>
<property name="DEPLOY_DIR" value="${basedir}/WebRoot"/>
<property name="locale.dir" value="en_US"/>
<property name="context.root" value="/UUMS"/>
<property name="server.name" value="localhost"/>
<property name="server.port" value="8088"/>
//加强ANT的编译功能
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="E:/cruisecontrol-bin-2.7.2/apache-ant-1.7.0/lib/ant-contrib-0.6.jar"/>
</classpath>
</taskdef>
//编译MXML文件
<target name="uums">
<mxmlc
//指定要编译的文件名称
file="${APP_ROOT}/uums.mxml"
keep-generated-actionscript="true"
//指定编译后生成的目录及文件名称
output="${DEPLOY_DIR}/UUMS.swf"
incremental="true"
//指定配置文件服务
compiler.services="${basedir}/WebRoot/WEB-INF/flex/services-config.xml" compiler.context-root="${context.root}">
//加载FLEX配置文件
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<source-path path-element="${FLEX_HOME}/frameworks"/>
<source-path path-element="${APP_ROOT}"/>
//编译过程中若提示en-us错误,需添加此行
<source-path path-element="${basedir}/flex_src/com/esri/solutions/flexviewer/nls/{locale}" />
//指定FLEX自带编译类库
<compiler.library-path dir="${FLEX_HOME}/frameworks" append="true">
<include name="libs" />
<include name="locale/{locale.dir}" />
</compiler.library-path>
//指定系统编译类库
<compiler.library-path dir="${basedir}/WebRoot/WEB-INF" append="true">
<include name="lib" />
</compiler.library-path>
//编译过程中引用到swc文件,需添加此行
<compiler.library-path dir="${basedir}" append="true">
<include name="flex_libs" />
</compiler.library-path>
</mxmlc>
</target>
//形成HTML格式
<target name="uumsHtml">
<html-wrapper
title="Welcome to My Flex App"
//输入生成的名称
file="UUMS.html"
height="100%"
width="100%"
bgcolor="red"
application="app"
//输入相应的SWf文件
swf="UUMS"
version-major="9"
version-minor="0"
version-revision="0"
history="true"
template="express-installation"
//指定输出路径
output="${DEPLOY_DIR}"/>
</target>