转载关于使用Ant打包Flex的一些脚本
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
<?xml version="1.0" encoding="utf-8"?>
<project name="Flex Ant Builder Sample Project" basedir=".">
<taskdef resource="flexTasks.tasks" classpath="D:/program files/Flex Builder 3/Flex Builder 3/sdks/flex_sdk_3/ant/lib/flextasks.jar"/>
<property name="FLEX_HOME" value="D:/program files/Flex Builder 3/Flex Builder 3/sdks/flex_sdk_3"/>
<property name="app_root" value="${basedir}"/>
<property name="deploy_dir" value="bin-debug"/>
<!-- could change -->
<!-- compiled mxml/as file name -->
<property name="filename" value="m_fangshou"/>
<!-- compiled mxml/as file ext -->
<property name="fileext" value="mxml"/>
<!-- third party swc-->
<!--<property name="third_party" value="d:/work/thirdparty/flexlib" />-->
<!-- modular application's main application filename -->
<property name="mainapp" value=""/>
<!-- output package direction,end with / -->
<property name="package" value="com/adobe/cairngorm/game/view/window/"/>
<property name="flashplayer" value="d:/eclipse/adobe/flex builder 2 plug-in/player/debug/saflashplayer.exe"/>
<property name="ie" value="c:\program files\internet explorer\iexplore.exe"/>
<!-- compile a mxml/as file -->
<target name="compile" depends="cleanCompile">
<mxmlc file="${app_root}/src/${package}${filename}.${fileext}" output="${deploy_dir}/${package}${filename}.swf" actionscript-file-encoding="utf-8" keep-generated-actionscript="false" warnings="false" incremental="true">
<!-- ***** source file path *******-->
<compiler.source-path path-element="${basedir}/src"/>
<!-- get default compiler options. -->
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<!-- List of path elements that form the roots of ActionScript class hierarchies. -->
<source-path path-element="${FLEX_HOME}/frameworks"/>
<!-- List of SWC files or directories that contain SWC files. -->
<compiler.library-path dir="${FLEX_HOME}/frameworks" append="true">
<include name="libs"/>
<include name="../bundles/{locale}"/>
</compiler.library-path>
<compiler.library-path dir="src/assets/swc" append="true">
<include name="chengchi.swc"/>
<include name="chengwai.swc"/>
</compiler.library-path>
<compiler.library-path dir="libs" append="true">
<include name="Cairngorm.swc"/>
</compiler.library-path>
<!-- ***** thirdparth swc ***** -->
<compiler.include-libraries dir="libs" append="true">
<include name="cairngorm.swc" />
</compiler.include-libraries>
<!-- set size of output swf file.
<default-size width="500" height="600" />
-->
</mxmlc>
<delete>
<!-- Deletes cache file -->
<fileset dir="${app_root}/${package}" includes="${fileName}*.cache" defaultexcludes="false"/>
</delete>
</target>
<!-- compile mxml file and Generate a Link Report for the embed module -->
<target name="CompileAndGenerateLinkReport">
<mxmlc file="${app_root}/${package}${fileName}.${fileExt}" link-report="${app_root}/${package}${fileName}_LinkReport.xml" output="${DEPLOY_DIR}/${package}${fileName}.swf" actionscript-file-encoding="UTF-8" keep-generated-actionscript="false" incremental="true">
<!-- Get default compiler options. -->
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<!-- List of path elements that form the roots of ActionScript class hierarchies. -->
<source-path path-element="${FLEX_HOME}/frameworks"/>
<source-path path-element="${app_root}"/>
<!-- List of SWC files or directories that contain SWC files. -->
<compiler.library-path dir="${FLEX_HOME}/frameworks" append="true">
<include name="libs"/>
<include name="../bundles/{locale}"/>
</compiler.library-path>
<!-- Set size of output SWF file. -->
<default-size width="500" height="600"/>
</mxmlc>
<delete>
<!-- Deletes cache file -->
<fileset dir="${app_root}/${package}" includes="${fileName}*.cache" defaultexcludes="false"/>
</delete>
</target>
<!-- compile Modular mxml file with mainApp's Link Report -->
<target name="CompileModuleWithLinkReport">
<mxmlc file="${app_root}/${package}${fileName}.${fileExt}" load-externs="${app_root}/${mainApp}_LinkReport.xml" output="${DEPLOY_DIR}/${package}${fileName}.swf" actionscript-file-encoding="UTF-8" keep-generated-actionscript="false" incremental="true">
<!-- Get default compiler options. -->
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<!-- List of path elements that form the roots of ActionScript class hierarchies. -->
<source-path path-element="${FLEX_HOME}/frameworks"/>
<!-- List of SWC files or directories that contain SWC files. -->
<compiler.library-path dir="${FLEX_HOME}/frameworks" append="true">
<include name="libs"/>
<include name="../bundles/{locale}"/>
</compiler.library-path>
<!-- Set size of output SWF file. -->
<default-size width="500" height="600"/>
</mxmlc>
<delete>
<!-- Deletes cache file -->
<fileset dir="${app_root}/${package}" includes="${fileName}*.cache" defaultexcludes="false"/>
</delete>
</target>
<!-- wrapper a swf with html express-installation template-->
<target name="wrapper" depends="cleanWrapper">
<html-wrapper title="Actor's lines in web" width="100%" height="100%" application="flexApp" swf="${fileName}" version-major="9" version-minor="0" version-revision="0" history="true" template="express-installation" output="${DEPLOY_DIR}/${package}"/>
<move file="${DEPLOY_DIR}/${package}index.html" tofile="${DEPLOY_DIR}/${fileName}.html"/>
<copy todir="${DEPLOY_DIR}/assets">
<fileset dir="./assets"/>
</copy>
</target>
<!-- clean preview previous compile file -->
<target name="cleanCompile">
<delete dir="${app_root}/${package}generated"/>
<delete>
<fileset dir="${deploy_dir}/${package}" includes="${fileName}*.swf"/>
</delete>
</target>
<!-- clean preview previous wrapper file -->
<target name="cleanWrapper">
<delete>
<!-- Deletes history.swf -->
<fileset dir="${DEPLOY_DIR}/${package}" includes="history.swf" defaultexcludes="false"/>
<!-- Deletes playerProductInstall.swf -->
<fileset dir="${DEPLOY_DIR}/${package}" includes="playerProductInstall.swf" defaultexcludes="false"/>
<!-- Deletes ${fileName}.html -->
<fileset dir="${DEPLOY_DIR}/${package}" includes="${fileName}*.html" defaultexcludes="false"/>
<!-- Deletes history.htm -->
<fileset dir="${DEPLOY_DIR}/${package}" includes="$history.htm" defaultexcludes="false"/>
<!-- Deletes history.js and AC_OETags.js -->
<fileset dir="${DEPLOY_DIR}/${package}" includes="*.js" defaultexcludes="false"/>
<!-- Deletes all assets -->
<fileset dir="${DEPLOY_DIR}/assets" includes="*.*"/>
</delete>
</target>
<target name="run" depends="compile" description="Compile and run it.">
<exec executable="${FLASHPLAYER}">
<arg value="${deploy_dir}/${package}${fileName}.swf"/>
</exec>
</target>
<target name="runie" depends="compile" description="Compile and run it.">
<exec executable="${IE}">
<arg value="${basedir}\${deploy_dir}\${package}${fileName}.html"/>
</exec>
</target>
</project>
posted on 2009-09-05 09:21 Louis Chan 阅读(480) 评论(0) 编辑 收藏 举报