I am a big fan of things that speed up my workflow. One of the things that I have been using a lot lately is ANT. ANT is a scripting language you can use from within Eclipse (and FDT). ANT is quite powerful. You can use it to show input dialogs, manipulate files, create files, compile an application, FTP, SVN and much much more!
In my last three projects I have been using the same ANT file and I think it is pretty useful for other Flash developers too. That’s why I want to share it with you.
My ANT file has four targets (functions).
The most important target is the first one, that’s the target I use the most. It compiles the actionscript into a SWF and then gives Firefox focus. If you want to know how this works see epologee.com/blog. I know a lot of people use the external player in FDT, I switched to Firefox because it is much faster and as a bonus you can use SWFAdress and other HTML stuff. In my opinion it’s much better to test from within the browser because it it behaves a bit different then external player in some occasions.
The second target (Create deployable SWF) creates a SWF which is smaller that the debug version; this is because I excluded the ‘verbose stacktraces’ on a large project this somethings takes 200kb of a SWF file.
Another thing I added to my ANT task is a conditional compilation arguments to the compiler. With these arguments it’s really easy to create a code block which only works for deployment, or a piece of code which only works for testing.
The code to do this looks like this:
CONFIG::Debug
{
// code for debugging
}
CONFIG::Release
{
// code for release version
}Another interesting thing I added was FTP, the only problem is it isn’t supported by FDT by default. You need to install a external script (pretty easy). All about FTP and ANT is on the blog of Erik van Nieuwburg.
Every time you compile using my script ANT creates a build.txt with some information about the build (deploment or development, time of compilation, filesize, user, etc) I store this information in Subversion to keep track of all the builds. I copy this to a folder on the webserver too. In another project I used a modified version of this code to update a Version.as file before compiling….
I created a video of my workflow to show you how it works.
If you have any feedback or suggestions please let me know. I created a zip file with all the files used in the video;
Jankees,
Great post, it is great you are sharing your learnings with the rest of the world.
Another good post uncovering the Power of ANT & FDT is from Alan Klement:
http://blog.alanklement.com/2009/08/10/fdt-and-ant-a-users-guide-part-i/
Bruno Fonzi at 22:46 on 11/12/2009
Hi Bruno,
Thanks for your message, I read the post by Alan it is pretty good. Are you working on FDT at Powerflasher?
Best,
jankees at 23:17 on 11/12/2009
@Jankees Yes I am ! I have just recently joined the Powerflasher FDT team in San Francisco. I used to work for Adobe before.
Bruno Fonzi at 00:34 on 12/12/2009
Nice post dude… spreading the ANT word!
Erik at 20:54 on 12/12/2009
I had some trouble with only having either one of the constants being true/false.
I had to clean FCSH before each compile to have it make any difference, it seems.
Karl Macklin at 11:52 on 07/01/2010
Thanks you, that’s very cool informations and shared files !
Joe at 17:51 on 20/01/2010
Hello, I just try the Launch in Firefox (reload) command. I copy the command in my build.xml file
I put your fresno file in ./build/tools/
But when I launch it I have the error :
Launch in Firefox (reload):
[exec] FAIL: EOF on connection
[exec] Result: 1
Did we change something in the fresno file ?
Any idea ?
Thanks !
Joe at 12:18 on 29/01/2010
The XML file was not shown in my previous comment:
Joe at 12:20 on 29/01/2010
There seems to be a problem with your fresno file, you could try to download it at their website
Jankees at 17:48 on 29/01/2010