我一直在搜索谷歌、Apache Docs*和FlashPunk论坛,寻找答案:我无法让Ant/Flex找到并编译*.AS格式的库文件夹。
这是我的build.xml。
<project>
<!-- Flex SDK Properties -->
<property name="FLEX_HOME" value="/opt/flex"/>
<property name="MXMLC.JAR" value="${FLEX_HOME}/lib/mxmlc.jar"/>
<!-- Project Properties -->
<property name="PROJECT_PATH"
value="/media/Lexar_32G/Dev/ActionScript/FlashPunk/FP_Tut_Vid_ep01"/>
<property name="SOURCE_PATH" value="${PROJECT_PATH}"/>
<property name="OUTPUT_PATH" value="${PROJECT_PATH}"/>
<property name="FLASHPUNK_PATH" value="/media/Lexar_32G/Dev/ActionScript/FlashPunk"/>
<!-- Fetch the JAR full of Flex tasks if it is not already in the source directory -->
<copy file="${FLEX_HOME}/ant/lib/flexTasks.jar" todir="${SOURCE_PATH}"/>
<!-- Add flextasks to the project -->
<taskdef resource="flexTasks.tasks" classpath="${SOURCE_PATH}/flexTasks.jar"></taskdef>
<!-- Release build Flash Player 10.1 -->
<target name="build">
<!-- Build the FlashPunk library -->
<echo message="building swc..." />
<compc output="FlashPunk.swc" keep-generated-actionscript="false"
incremental="false" optimize="false" debug="true" use-network="false">
<include-sources dir="${FLASHPUNK_PATH}/net"
includes="**/* flashpunk/utils/* flashpunk/masks/*"
excludes="**/*.TTF **/*.png"/>
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
</compc>
<echo message="building swf..." />
<mxmlc
file="${SOURCE_PATH}/epOne.as"
output="${OUTPUT_PATH}/epOne.swf"
debug="false"
incremental="false"
strict="true"
accessible="false"
link-report="link_report.xml"
static-link-runtime-shared-libraries="true">
<optimize>true</optimize>
</mxmlc>
</target>
导致许多类型为"Definition net.flashbunk.masks:Grid cannot found"的错误,即使当我打开目录时,我可以看到*.AS文件就在那里。
很抱歉,如果这是非常基本的。我正在从文档和教程中拼凑Ant的知识。
*我决定使用Ant,因为无论是针对Windows的FlashDevelop还是针对Linux的Eclipse似乎都不适合我
这(基本上)是固定的。我没有达到只有一个未编译的FlashPunk库副本的目标,但我能够通过将整个库复制到我的源路径来至少编译SWF。幸好它没有那么大。
Apache Ant命令看起来是这样的:
<copy todir="${SOURCE_PATH}/net">
<fileset dir="/media/Lexar_32G/Dev/ActionScript/FlashPunk/net"/>
</copy>
事实证明,Flex不需要额外的命令来为我设置命名空间。此外,在编译最终的SWF之前,我停止了将库编译为SWC的尝试。因此,生成的build.xml看起来是这样的:
<!--
build.xml
SquareCrow, June 2011
Apache Ant makefile
-->
<project>
<!-- Flex SDK Properties -->
<property name="FLEX_HOME" value="/opt/flex"/>
<property name="MXMLC.JAR" value="${FLEX_HOME}/lib/mxmlc.jar"/>
<!-- Project Properties -->
<property name="PROJECT_PATH" value="/media/Lexar_32G/Dev/ActionScript/FlashPunk/FP_Tut_Vid_ep01"/>
<property name="SOURCE_PATH" value="${PROJECT_PATH}"/>
<property name="OUTPUT_PATH" value="${PROJECT_PATH}"/>
<property name="FLASHPUNK_PATH" value="/media/Lexar_32G/Dev/ActionScript/FlashPunk"/>
<!-- Fetch the JAR full of Flex tasks if it is not already in the source directory -->
<copy file="${FLEX_HOME}/ant/lib/flexTasks.jar" todir="${SOURCE_PATH}"/>
<!-- Add flextasks to the project -->
<taskdef resource="flexTasks.tasks" classpath="${SOURCE_PATH}/flexTasks.jar"></taskdef>
<!-- Fetch the FlashPunk files and put them in their own folder -->
<copy todir="${SOURCE_PATH}/net">
<fileset dir="/media/Lexar_32G/Dev/ActionScript/FlashPunk/net"/>
</copy>
<!-- Release build Flash Player 10.1 -->
<target name="build">
<echo message="building swf..." />
<mxmlc
file="${SOURCE_PATH}/epOne.as"
output="${OUTPUT_PATH}/epOne.swf"
debug="false"
incremental="false"
strict="true"
accessible="false"
link-report="link_report.xml"
static-link-runtime-shared-libraries="true">
<optimize>true</optimize>
</mxmlc>
</target>
</project>
很简单,不是吗?