Skip to content

Instantly share code, notes, and snippets.

@zrong
Created May 5, 2011 13:47
Show Gist options
  • Save zrong/957056 to your computer and use it in GitHub Desktop.
Save zrong/957056 to your computer and use it in GitHub Desktop.
同项目中编译多个主文件,使用ant tagetname实现调用
# 设置FLEX SDK的路径
FLEX_HOME=c:/Program Files/Adobe/FlashBuilder4Plug-in/sdks/4.1.0
# 设置源文件路径
# {$basedir} 就是本文件所在的目录
SRC_DIR =${basedir}/src
# libs目录,一般用来放swc文件
LIBS_DIR =${basedir}/libs
# 这个就是Flash Builder建立的bin-debug
DEPLOY_DIR = ${basedir}/bin-debug
#自定义的类库源码
LIBS_DUDU = e:/works/duduw_as3lib/src
<project name="同项目中编译多个主文件" default="ba">
<!--同项目中编译多个主文件,使用ant tagetname实现调用-->
<!-- 载入配置文件 -->
<property file="build.properties" />
<!-- 确定flexTasks.jar的位置 -->
<taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar"/>
<target name="ba">
<antcall target="init" />
<antcall target="build">
<param name="main" value="A" />
</antcall>
<antcall target="fdb">
<param name="main" value="A" />
</antcall>
</target>
<target name="bb">
<antcall target="init" />
<antcall target="build">
<param name="main" value="B" />
</antcall>
<antcall target="fdb">
<param name="main" value="B" />
</antcall>
</target>
<!-- 清理部署目录中的内容 -->
<target name="init">
<delete dir="${DEPLOY_DIR}/Emcee.swf" />
<delete dir="${DEPLOY_DIR}/assets/magic" />
<!-- 将资源目录复制到部署目录 -->
<copy todir="${DEPLOY_DIR}/assets/magic">
<fileset dir="${SRC_DIR}/assets/magic" />
</copy>
</target>
<!-- 编译主界面 -->
<target name="build">
<mxmlc file="${SRC_DIR}/${main}.as" output="${DEPLOY_DIR}/${main}.swf">
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<source-path path-element="${SRC_ZRONG}" />
<compiler.library-path dir="${basedir}" append="true">
<include name="libs" />
</compiler.library-path>
<!-- 必须加上这行,如果不加,当使用[Embed]的标签的时候,就会出现VerifyError: Error #1014: 无法找到类 。 原因应该是没有将mx.core包编译进入。官方文档说这个属性默认是true, 不要相信它-->
<static-link-runtime-shared-libraries>true</static-link-runtime-shared-libraries>
<!-- 编译成可调试的版本 -->
<compiler.debug>true</compiler.debug>
</mxmlc>
</target>
<!-- 打开调试器进行调试 -->
<target name="fdb">
<!-- 不能直接调用fdb,因为这样不会打开新的命令行窗口,必须使用/K或者/C参数,加上start来启动fdb -->
<exec executable="cmd" spawn="true" osfamily="windows">
<arg line="/K start fdb ${DEPLOY_DIR}/${main}.swf" />
</exec>
</target>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment