<?xml version="1.0"?>
<project name="AntExample" default="build" basedir=".">

	<!-- property has to be name FLEX_HOME to work with Flex Ant Tasks -->
	<property name="FLEX_HOME"   value="D:/tools/moxie/sdks/3.0.0" />
	
	<!-- this is default and redundant but you could switch to a custom flex-config.xml -->
	<property name="flex.config"   value="${FLEX_HOME}/frameworks/flex-config.xml" />
	
	<property name="mxmlc.incremental" value="false" />
	<property name="mxmlc.keep_generated_as" value="false" />
	
	<property name="source.mxml" value="src/AntExample.mxml" />
	<property name="deploy.dir" value="${basedir}/bin-debug" />
	<property name="deploy.swf" value="${deploy.dir}/AntExample.swf" />
	<property name="html.title" value="Ant Example" />
	
	<!-- Define Flex Ant Tasks (http://labs.adobe.com/wiki/index.php/Talk:Flex_Ant_Tasks) -->
	<taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" />

	<!-- default target builds all -->
	<target name="build" depends="compile-flex, copyRSLs, generate-html" />
	
	<!-- Compile Flex MXML Application -->
	<target name="compile-flex" description="Compile MXML file to SWF application.">
		
		<mxmlc file="${source.mxml}"
			output="${deploy.swf}"
			locale="en_US"
			static-rsls="false"
			actionscript-file-encoding="UTF-8" 
			incremental="${mxmlc.incremental}" 
			keep-generated-actionscript="${mxmlc.keep_generated_as}">
			
			<!-- optional -->
			<load-config filename="${flex.config}" />
			
			<!-- Add source classpath -->
            <source-path path-element="${basedir}/src" />
			
			<!-- RSLs -->
			<runtime-shared-library-path path-element="${FLEX_HOME}/frameworks/libs/framework.swc">
				<url rsl-url="framework_3.0.0.477.swz" />
				<url policy-file-url="" />
				<url rsl-url="framework_3.0.0.477.swf" />
				<url policy-file-url="" />
			</runtime-shared-library-path>
			
			<runtime-shared-library-path path-element="${FLEX_HOME}/frameworks/libs/datavisualization.swc">
				<url rsl-url="datavisualization_3.0.0.477.swz" />
				<url policy-file-url="" />
				<url rsl-url="datavisualization_3.0.0.477.swf" />
				<url policy-file-url="" />
			</runtime-shared-library-path>
				
			<runtime-shared-library-path path-element="${FLEX_HOME}/frameworks/libs/rpc.swc">
				<url rsl-url="rpc_3.0.0.477.swz" />
				<url policy-file-url="" />
				<url rsl-url="rpc_3.0.0.477.swf" />
				<url policy-file-url="" />
			</runtime-shared-library-path>
			
		</mxmlc>
		
	</target>
	
	<!-- Copy Flex Framework files -->
	<target name="copyRSLs">
		
		<copy todir="${deploy.dir}" overwrite="true">
			<fileset dir="${FLEX_HOME}/frameworks/rsls" />
		</copy>
		
	</target>
	
	<!-- Generate index.html to embed swf -->
	<target name="generate-html" description="Generate HTML page embedding the SWF application.">
		
		<html-wrapper title="${html.title}" 
			height="100%" width="100%" application="app" swf="AntExample" 
			version-major="9" version-minor="0" version-revision="60" 
			template="client-side-detection" history="true"
			output="${deploy.dir}" />
		
	</target>

</project>

