by Tomasz Stocki on October 19, 2008 Avg 原载: Flex cookbook beta 翻译及整理:LiGL
你试图使用ANT编译SWC文件. You want to compile your swc using ant.
使用Adobe在Flex SDK中提供的Flex ANT任务来编译你的应用 Use flex ant tasks provided by adobe in flex SDK to compile your application.
在部署应用程序时, 我们可以使用ANT这个强大的工具—它可以帮助我们运行程序, 运行命令行, 复制文件,等等…
When deploying flex application we can use very powerful tool – ant. With his help we can launch applications, run command line tools, copy files and much, much more (see: http://ant.apache.org/manual/index.html)
在开始之前, 如果你使用的时FlexBuilder单独版本[非Eclipse插件版], 你需要先安装ANT
Before we start you should install ANT on your flex builder if you have stand alone version.
参考: See article “Installing Ant in Flex Builder 3” at :
http://blog.jodybrewster.net/2008/04/09/installing-ant-in-flex-builder-3/
安装完毕之后, 只需要建立以下两个文件: After that, just create two files in project:
build.properties: —–该文件用于存储Bulid.xml中用到的属性, 便于管理与查看
###### Flex Properties ##############################
# change this path to your flex sdk directory
# Use "/" in your directory path e.g. C:/FlexSDK/3.0.0
FLEX_HOME=C:/flex_sdk_4.0
###### Project Properties ###########################
src-dir=${basedir}/src
build.xml:
<project name="Ant build SWC sample" basedir="." default="build SWC">
<!-- load user configuration properties -->
<property file="build.properties" />
<taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" />
<!-- =================================
target: build SWC
================================= -->
<target name="build SWC">
<compc output="${basedir}/swc/sample.swc"
include-classes="tom.hallo.CHalloWorld">
<source-path path-element="${src-dir}" />
</compc>
</target>
</project>
第一个文件中存储了关于本机FlexSDK及工程的目录. First file build.properties, holds info about location FlexSDK and files structure in your project.
在Build.xml中的代码读取第一个文件并运行ANT的compc任务生成swc文件. Code in build.xml loads build.properties and run ant task compc
to generate swc.
在FlexBuilder中, 只需要将Build.xml从导航栏中拖到Ant视图中, 然后双击’build SWC’任务. In Flex Builder, just drag and drop build.xml from Flex Navigator to Ant view and double “click build SWC” task.
// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.