开发者

Flex 4 + Apache Ant, Cannot Load ActionScript Libraries

I have been searching google, Apache Docs*, and FlashPunk forums looking for an answer to this: I cannot get Ant/Flex to find and compile a folder of libraries in *.AS format.

Here is my 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"/&g开发者_开发问答t;
        <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>

Results in many errors of the type "Definition net.flashpunk.masks:Grid could not be found" even though when I open the directories I can see the *.AS files right there.

Sorry if this is very basic. I am piecing together knowledge of Ant from docs and tutorials.

*I decided to use Ant because neither FlashDevelop for Windows nor Eclipse for Linux seemto work for me.


This was (basically) fixed. I did not meet my goal of having only one copy of the uncompiled FlashPunk library, but I was able to get the SWF to at least compile by copying the entire library to my source path. Good thing it wasn't that large anyway.

Apache Ant command looks like so:

<copy todir="${SOURCE_PATH}/net">
    <fileset dir="/media/Lexar_32G/Dev/ActionScript/FlashPunk/net"/>
</copy>

Did not turn out to need extra commands to let Flex set up the namespaces for me. Additionally, I stopped trying to compile the library as a SWC before I compiled the final SWF. Therefore, the resulting build.xml looks like so:

<!--
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>

Simple, no?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜