Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling mxml files with ant and flex sdk

I am just getting started with flex and am using the SDK (not Flex Builder). I was wondering what's the best way to compile a mxml file from an ant build script.

like image 507
sutee Avatar asked Sep 16 '08 23:09

sutee


2 Answers

The Flex SDK ships with a set of ant tasks. More info at:

http://livedocs.adobe.com/flex/3/html/help.html?content=anttasks_1.html

Here is an example of compiling Flex SWCs with ant:

http://www.mikechambers.com/blog/2006/05/19/example-using-ant-with-compc-to-compile-swcs/

mike chambers

like image 71
mikechambers Avatar answered Sep 20 '22 12:09

mikechambers


I would definitely go with the ant tasks that are included with Flex, they make your build script so much cleaner. Here is a sample build script that will compile and then run your flex project

<?xml version="1.0"?>

<project name="flexapptest" default="buildAndRun" basedir=".">

    <!-- 
        make sure this jar file is in the ant lib directory 
        classpath="${ANT_HOME}/lib/flexTasks.jar" 
    -->
    <taskdef resource="flexTasks.tasks" />
    <property name="appname" value="flexapptest"/>
    <property name="appname_main" value="Flexapptest"/>
    <property name="FLEX_HOME" value="/Applications/flex_sdk_3"/>
    <property name="APP_ROOT" value="."/>
    <property name="swfOut" value="dist/${appname}.swf" />
    <!-- point this to your local copy of the flash player -->
    <property name="flash.player" location="/Applications/Adobe Flash CS3/Players/Flash Player.app" />

    <target name="compile">
        <mxmlc file="${APP_ROOT}/src/${appname_main}.mxml"
            output="${APP_ROOT}/${swfOut}" 
            keep-generated-actionscript="true">

            <default-size width="800" height="600" />
            <load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
            <source-path path-element="${FLEX_HOME}/frameworks"/>
            <compiler.library-path dir="${APP_ROOT}/libs" append="true">
                <include name="*.swc" />
            </compiler.library-path>
        </mxmlc>
    </target>

    <target name="buildAndRun" depends="compile">
        <exec executable="open">
            <arg line="-a '${flash.player}'"/>
            <arg line="${APP_ROOT}/${swfOut}" />
        </exec>
    </target>

    <target name="clean">
        <delete dir="${APP_ROOT}/src/generated"/>
        <delete file="${APP_ROOT}/${swfOut}"/>
    </target>

</project>
like image 24
jgormley Avatar answered Sep 23 '22 12:09

jgormley