Apr
26

FlashAntTasks – Compiling Flash Movies With Ant

If you’ve seen Mike Chambers flashcommand implementation you’ll notice that it only works on the mac.  We have a lot of people at my office on Windows and I wanted to provide them something that could also work on a Windows computer.  Plus I wanted something a little cleaner, easier to learn and a bit more elegant than most of the solutions out there.  So I created FlashAntTasks.  Its a jar file that you reference in your class file that creates flash tasks that compile separate movies.  I’m posting it up on Google code so everyone can enjoy.  So enough with the fluff, here’s the details

WINDOWS USERS – you need to pass in flashcommand the flashapp attribute with the uri to your flash.exe like

You can download the code at http://code.google.com/p/flashanttasks/.

<?xml version="1.0" encoding="UTF-8"?>
<project name="FlashAntTasks" basedir="." default="Open in Browser">
 
    <description>
        simple example build file
    </description>
 
    <!-- os specific properties -->
    <property name="os" value="${os.name}"/>
    <echo message="Using ${os.name}.properties"/>
    <property file="${os.name}.properties"/>
 
	<!-- Include the Flash Ant Tasks Jar here, also make sure you 
                reference the FlashAntTasks.properties file which is 
                bundled in the jar file -->
    <taskdef resource="FlashAntTasks.properties" classpath="lib/FlashAntTasks.jar"/>
 
	<!-- Project Specific Properties -->
	<property name="html.filename" value="index_full.html" />
	<property name="local.path" value="${basedir}/wwwroot//${html.filename}" />
 
        <!-- make sure to reference the fla dir and your output dir -->
	<property name="fla.dir" value="${basedir}/flash" />
	<property name="swf.output.dir" value="${basedir}/wwwroot/assets/swfs" />
 
 
	<!-- TARGETS -->
	<target name="Compile Additional Swfs">
		<flashcommand >
			<movie export="true" source="${fla.dir}/site.fla" output="${swf.output.dir}/site.swf" />
			<movie export="true" source="${fla.dir}/shared.fla" output="${swf.output.dir}/shared.swf" />
		</flashcommand>
	</target>
 
	<target name="Compile Shell" depends="Compile Additional Swfs">
		<flashcommand >
			<movie export="true" source="${fla.dir}/shell.fla" output="${swf.output.dir}/shell.swf" />
		</flashcommand>
	</target>
 
	<target name="Windows Example" depends="Compile Additional Swfs">
                      <!-- WINDOWS USERS: flashapp attribute is required -->
		<flashcommand flashapp="c:\\Program files\\Adobe\\Flash.exe">
			<movie test="true" source="${fla.dir}/shell.fla" output="${swf.output.dir}/shell.swf" />
		</flashcommand>
	</target>
 
	<target name="Compile Shell" depends="Compile Additional Swfs">
		<flashcommand >
			<movie export="true" source="${fla.dir}/shell.fla" output="${swf.output.dir}/shell.swf" />
		</flashcommand>
	</target>
 
 
	 <!-- Open in local browser -->
	<target name="Open in Browser" depends="Compile Shell">
		<exec executable="open">
			<arg line="-a ${browser} ${local.path}" />
		</exec>
	</target>
 
</project>
Tagged with:


 

 

 

comments

5 Responses to “FlashAntTasks – Compiling Flash Movies With Ant”

  1. Julian Dolce Says:

    Thanks a lot for this. I have been using it for the last couple of days with great success.

    It would be great if the temp jsfl file would close the file it opened after it was published. Or maybe if you could specify if you want it closed. It should be as simple as adding to extra commands in the temp jsfl file that gets created.

  2. matt Says:

    hey this is awesome dude, just what i need to publish about 200 flas :)

  3. Sean McAuliffe Says:

    @Julian – you can add the closeDocAfterComplete parameter to each movie node in the build.xml.

  4. Joe Says:

    Hello,

    This task is really great. Reaaly cool to have the source too.
    I have just found a bug in a special case. When your build file, is not named exactly “build.xml”, the task crash.

  5. Daniel Zollinger Says:

    Nice work. Cheers for this!

    I’m having a little trouble, as Flash hangs on me, but I suspect this is Flash’s crappiness and not the project.

    Anyway, thanks for taking the time to share your work.

leave a reply