====== Apache Ant ======
* Ant Homepage - [[http://ant.apache.org/]]
* Ant Wiki - [[http://wiki.apache.org/ant/]]
Ant is an XML language used to automate compiling of software similar to [[wp>Make]]. It's mostly used by Java developers but is becoming more common among Flash developers because it's available in [[Eclipse]] and it works well with [[MTASC]]. Commands can be added to Ant through plugins written in Java.
===== As2ant - Swf, Mtasc and Swfmill Ant Tasks =====
To integrate mtasc or swfmill into your ant build script, you can either work with the executable task directly, as explained in the next item, or you can use ant tasks that were specifically created for this. Using specific ant tasks, instead of the executable ant task, feels much more natural, is easier to learn and provides you in some cases with some extra and useful functionalities.
You can use the:
* Mtasc Ant Task to compile your code with the Motion-Twin ActionScript 2.0 Compiler (Mtasc).
* Swfmill Ant Task to process swfs xml-based with the Swfmill XML-based SWF Processing Tool.
* Swf Ant Task to create swfs with library assets et cetera and to compile classes into it.
While the Mtasc and Swfmill Ant Tasks act mainly as mediator between ant and mtasc or swfmill respectively, the Swf Ant Task merges the possible usages of mtasc and swfmill into one task. This provides you with an easy way to compile classes into your swf and to include library symbols like movieclips and fonts and shared libraries into your swf.
Following is a sample of how your build.xml file may look like. Take a look at the comments of what is being done with certain declarations.
This works basically the same with the Swfmill and Mtasc Ant Tasks, the supported attributes are of course different.
For more information on these tasks take a look at the samples provided in the donwloadable zip file and at the api documentation of each task which also includes sample code and the list of supported attributes.
[[https://sourceforge.net/project/showfiles.php?group_id=94206&package_id=164902|Download As2ant - Swf, Mtasc and Swfmill Ant Tasks]] (these tasks were created by [[http://www.simonwacker.com|Simon Wacker]] and are part of the [[http://www.as2lib.org|As2lib - Open Source ActionScript 2.0 Library]]).
===== Ant Examples for Flash Development =====
Here is a simple build.xml file for Eclipse that can compile your project using MTASC using the convenient green arrow button at the top of the screen.
To get this to work, create a new file at the root of your project and save it as build.xml. Next open the file and paste the following XML into it. Then you will need to modify the values of all the property tags appropriately and save the file. You should now be able to run the Ant task from the green button.
Here's another example. It creates a swf with swfmill, uses mtasc to inject bytecode, and then, only if all goes well, displays the swf in the standalone player.
simple build file for flash projects
[[Scott Whittaker]]: The following is an example of a simple Ant task which allows you to define the properties of your .swf, compiles it with MTASC and then opens an HTML page which contains the Flash movie. It uses a combination of techniques used in the examples above and includes a couple of comments to explain some of the ANT syntax used:
For more a more detailed guide to Ant, see the [[http://wiki.apache.org/ant/|Ant Wiki]], specifically the [[http://wiki.apache.org/ant/AntNewbies|AntNewbies]] and [[http://wiki.apache.org/ant/AntTutorials|AntTutorials]] pages.
You can also read [[carlos_rovira|Carlos Rovira]]'s article [[http://actionscript.com/Article/tabid/54/ArticleID/Far-Beyond-Open-Source-Flash-Development/Default.aspx|Far Beyond Open Source Flash Development]] for [[AMES]] development related examples and useful hints.
===== Using Ant to unpack SWC Files =====
[[Ralb Bokelberg]]: The following script unpacks a F7 component. It also provides an example of ant macros.