#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2011
    Posts
    7
    Rep Power
    0

    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 ActionScript libraries (FlashPunk).

    Here is my build.xml.

    Code:
    <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>
    	
    </project>
    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.
  2. #2
  3. No Profile Picture
    Gotta get to the next screen..
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2003
    Location
    Legion of Dynamic Discord
    Posts
    6,678
    Rep Power
    3164
    Hi, where do you have the FlashPunk files? They should not be in the com directory. From the error message they should be in a directory called net in the project root directory.
    Quis custodiet ipsos custodes?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2011
    Posts
    7
    Rep Power
    0

    Location of FlashPunk


    Originally Posted by Tann San
    Hi, where do you have the FlashPunk files? They should not be in the com directory. From the error message they should be in a directory called net in the project root directory.
    Tann,

    I have stored FlashPunk in a directory other than the build directory because it will be used by several projects. The location is stored in a property for this project, here:

    Code:
    <property name="FLASHPUNK_PATH" value="/media/Lexar_32G/Dev/ActionScript/FlashPunk"/>
    Is this allowed? May I point to ActionScript files outside the project and build them in?

    Thanks,
    ~SC
  6. #4
  7. No Profile Picture
    Gotta get to the next screen..
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2003
    Location
    Legion of Dynamic Discord
    Posts
    6,678
    Rep Power
    3164
    You also have this bit:

    <include-sources dir="${FLASHPUNK_PATH}/net"

    I think that should be:

    <include-sources dir="${FLASHPUNK_PATH}"
    Quis custodiet ipsos custodes?
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2011
    Posts
    7
    Rep Power
    0

    [FIXED] Flex 4 + Apache Ant, Cannot Load ActionScript Libraries


    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:
    Code:
    <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:

    Code:
    <!--
    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?

IMN logo majestic logo threadwatch logo seochat tools logo