You can now specify the swfmill xml directly in the task. The advantages are that you have only one file to maintain (build.xml) and that you can use ant properties within the swfmill xml.
-
<swf src="${src.dir}/com/simonwacker/ant/Sample.as" dest="${build.dir}/sample.swf">
-
<xml>
-
<![CDATA[
-
<movie width="300" height="100" framerate="31">
-
<background color=’#FF8A00′/>
-
<frame>
-
<library>
-
<clip id="simonwacker" import="${res}/simonwacker.jpg"/>
-
<font id="pixel" import="${res}/pixel.ttf"/>
-
</library>
-
</frame>
-
</movie>
-
]]>
-
</xml>
-
</swf>
Further enhancements are:
[+] org.as2lib.ant.Mtasc
Added special XML support for As2lib Bean Factory and Context.
[+] org.as2lib.ant.Swfmill / org.as2lib.ant.Swf
Added support for specifying the swfmill xml directly in the tasks.
[+] org.as2lib.ant.Swf
Added support for overriding font family names.
[+] org.as2lib.ant.Swfmill / org.as2lib.ant.Swf
Added support for extra verbose debugging output.
Download As2ant 1.5 from sourceforge.net
Download As2ant 1.5 from simonwacker.com
I hope you enjoy the new features!

23 Responses to “As2ant 1.5: Specify Swfmill XML within Task”
Great work Simon. One question: is it necessary to wrap the swfmill XML in a CDATA tag as in your example above?
Hi Steve,
wrapping the swfmill XML in a CDATA tag is sadly necessary, because the XML gets added to the task as String and we have to mark the XML data so that it is not interpreted.
I may make a object-oriented representation of the simple swfmill XML format and construct the XML to pass to swfmill via this representation. But this is not worth the effort, and would demand an update if the swfmill XML format changes.
Cheers,
Simon
Simon: I don’t know how Ant works (and I’ve never tried processing XML in Java) but could you not just define an object to handle the top-level movie element and use it to store the XML as a string?
Hi Steve,
Ant works pretty simple. Every element- or attribute-name is interpreted as a create-, set- or add-method on the task, or on the object created by another nested element. This means that if you declare in the task, the createMovie method will be invoked. If there is a element inside the element, then the createBackground method will be invoked on the returned movie object and so on.
I don’t think that this fundamental behaviour of Ant passing the build.xml can be changed. But I’ll try to talk to some Ant gurus to find a solution.
Nevertheless, I’m curious to know why you don’t like the CDATA. Is it just because of the inconvenience of using it?
Greetings,
Simon
Hi, wanna try as2ant but I don’t know where to copy the as2ant.jar file to have the tasks available in Eclipse (haven’t found any info on how to install as2ant anywhere which makes it a bit of a riddle for Ant non-pro’s).
Hi Sascha,
as2ant does not need any installation. You just have to point to either the folder were the compiled sources reside on or to the jar in the taskdef in your build.xml file (the samples show the former usage).
<taskdef name=”swf” classname=”org.as2lib.ant.Swf” classpath=”theRelativeOrAbsolutePathToTheJar.jar”/>
You can then use the task like any other task.
If you do not wanna make the taskdef in every build.xml the Eclipse Ant plugin offers the functionality to specify your own global tasks.
Got to Window / Preferences / Ant / Runtime. Add an external jar in the Classpath tab. The open the Tasks tab and add the tasks you need: Specify a name, select the jar you added previously and select the task class file (Mtasc.class, Swf.class, …).
You can then use the task without making a taskdef in the build.xml. (this is of course not as2ant specific, and is also explained in the eclipse ant plugin docu)
I hope the above explanations help you to get the ant tasks to work.
I’ll add explanations of how to set up everything with and without eclipse in the next release.
Greetings,
Simon
Thanks Simon! Got it working so far, just one thing is not clear … how do I tell where to find the tool executables (mtasc, swfmill)? Or would I have to define properties for them in the build file like I normally did before with my ‘own’ build files?
Hi Sascha,
if you work with Windows you can add the folder where mtasc.exe and swfmill.exe reside in to the PATH environment variable (there is something similar in Linux).
You can also set the paths to the *.exe files directly in the task.
<swf … mtasc=”tool/mtasc.exe” swfmill=”tool/swfmill.exe”/>
Greetings,
Simon
Hi Simon,
yes I’ve added the tools to the path (on windows btw) but I’m getting this error when trying to build…
BUILD FAILED
E:\Projects\Eclipse\as2ant\samples\mtasc\build.xml:19: Error running mtasc compiler.
Any idea what could be the problem?
Hi Sascha,
this error is thrown when trying to execute the mtasc.exe results in an IOException. As far as I know this is only the case when mtasc.exe could not be found.
Try to specify the path to the mtasc.exe directly. If this does work, there must be some problem with your PATH environment variable, if not open Mtasc.java, go to line 1384 and add “e.printStackTrace()”, then compile the class (you can use the given build.xml to do so), run your build.xml again and show me what exact error occurs.
Greetings,
Simon
Thanks alot Simon,
but somehow I’m still doing something wrong. I’ve added the as2ant tasks in Eclipse under Ant/RunTime but if I want to use the tasks in a buildfile and paste the typedef into it, it tells me an error (or rather a warning), taskdef class org.as2lib.ant cannot be found! Any idea why this happens?
PS: If I remove the classpath from the typedef, it doesn’t show a warning anymore. They are optional. Are the classpathes relevant?
Hi Sascha.
If you add the classpath in Preferences/Ant/Runtime/Classpath you do not have to specify a classpath in your taskdef. If you Also added the task under Preferences/Ant/Runtime/Tasks you do not even have to make a taskdef in the build.xml.
If you do neither of the above you must specify a taskdef in your build.xml with classname and classpath.
If taskdef gives you a warning that there is no class with name org.as2lib.ant, you should specify a class name and not a package name. org.as2lib.ant is the package while org.as2lib.ant.Mtasc or .Swf or .Swfmill is the task you want to define.
If you still get a warning then your classpath must be wrong; it must point to the jar or to the src directory of the as2ant distribution.
If it still does not work, post the build.xml you use, please.
Greetings,
Simon
Thanks Simon! Got all working fine now! Thanks for the time and explanations!
Hi, me again |-)
the as2ant tasks are quite nice now that true/false properties can be used directly in the arguments! However I found one small odd thing that happens with the mtasc task that I didn’t had before …
I’m using two mtasc targets, one for a debug version that uses the arguments -pack to force inclusion of the debug class I’m using and -trace to load to my custom trace method. These are used with MTASC’s custom trace functionality.
The other target for release doesn’t have these two arguments to filter out all occuring traces in the source code.
My custom trace function supports more than one argument and it seems that the as2ant mtasc task doesn’t like this. If I have a trace in my sources that has more than one argument, mtasc complains and build fails. This somehow compromises the idea behind using MTASC’s custom trace to use a debug and a release target since I have to comment all these trace out manually.
I was wondering if there is a workaround or if it could be changed in a future as2ant to support multiple trace arguments?
Either way thanks for the great tool!
Hi Sascha,
as2ant has nothing to do with the compilation of your classes (this is what Mtasc does), so this behaviour is not caused by the task (at least not directly). The task just acts as delegate for conveniently combining Ant and Mtasc.
Is there any difference between the mtasc command you normally use and the one produced by the task? Or does Mtasc normally produce a warning if you use more than one paramter for trace?
Greetings,
Simon
hi,
is there any way to add undefault arguments to mtasc call like those used in hamtasc. A generic arg parameter would be perfect.
Thanks. very usefull tasks.
Hi Dougi,
yes there is: <argument name=”-myargument” value=”myvalue”/>
If it is a flag, just don’t specify a value.
Greetings,
Simon
sorry for my previous post, it’s already implemented.
Hi Simon,
Firstly, congrats on as2ant - great stuff. Just got going for the first time on Swfmill, Ant and MTASC and it’s working out really well.
Just a quick possible bug-report - when using the xsl option on the swfmill task, for example:
The command line generated misses out the name of the xsl file - e.g. produces this:
swfmill xslt test.xml test.swf
rather than this:
swfmill xslt test.xsl test.xml test.swf
Which obviously means that swfmill chokes on it.
HTH,
Ian
*sigh* Obviously that ate my example XML - let’s try again…
Just a quick possible bug-report - when using the xsl option on the swfmill task, for example:
<swfmill xsl=”config.xsl” src=”test.xml” dest=”test.swf”/>
The command line generated misses out the name of the xsl file - e.g. produces this:
swfmill xslt test.xml test.swf
rather than this:
swfmill xslt test.xsl test.xml test.swf
Hi Ian,
thanks for the report, I’ll fix it. (I should have written Unit Tests; sorry for the inconvenience)
Next release on Saturday next week.
Greetings,
Simon
Hi Simon,
No problems - and no hurry. I can always get around it using an <exec> - I just prefer as2ant.
Cheers,
Ian