hi everybody,
yesterday i found a way to use javascript in an ant build file. i know
it would make more sense to write a task in java, but i know javascript
and gave it a try.
how to use javascript in ant is described here
http://www.sitepen.com/ant/javascript.html.
i have an ant property file in my flame folder like this
flame.mtasc = c:/molokai/app/flame/mtasc.exe
flame.mtasc.classpath = c:/Programme/Macromedia/Flash MX 2004/de/First
Run/Classes
flame.mtasc.target = main.swf
flame.mtasc.mainclass = Main.as
flame.swfmill = c:/molokai/app/flame/swfmill.exe
flame.naturaldocs = c:/molokai/app/naturaldocs/NaturalDocs.bat
this property file is registred in the global ant preferences.
the next thing is my build file (see attachments).
it has four important targets (clean, precompile,compile,documentation)
precompile creates a file called library.xml which contains recursively
all swf and png files in a given library folder and feeds swfmill with
this xml file.
the rules for ids are simple
/library/test.swf -> test_swf
/library/foo/test.png ->foo_test_png
ive created the buildfile with too much wine and it was quite late. but
i will clean it up and start document it this weekend.
If anyone is interested i would write a small tutorial how to set this
up and to use this.
one aspect still bothers me.
two different way of working with libraries
* we have a library folder with assets becoming an swf library with swfmill
* we have an fla file we use as an library.
it should be possible to switch between those two different workflows
via a simple property.
i would like to know how other flame programmers organise their files.
perhaps flame (osflash) could serve a coding guideline and a filehierarchy.
markus
<project name="FLAME" basedir="." default="info">
<description>simple build file for flash projects</description>
<!-- folder info -->
<property name="src" location="src"/>
<property name="library" location="library"/>
<property name="build" location="build"/>
<property name="doc" location="doc"/>
<property name="library.file" location="library.xml"/>
<target name="clean">
<delete file="${build}/${targetswf}" quiet="true"/>
<delete dir="${doc}" quiet="true"/>
</target>
<target name="info">
<echo>${flame.mtasc.classpath}</echo>
</target>
<target name="precompile">
<delete file="${library.file}"/>
<echo file="${library.file}" append="false"><![CDATA[<?xml version="1.0" encoding="iso-8859-1" ?>
<movie width="320" height="240" framerate="31">
<background color="#ffffff"/>
<frame>
<library>]]></echo>
<script language="javascript"> <![CDATA[
// import statements
// importPackage(java.io);
importClass(java.io.File);
// Access to Ant-Properties by their names
dir = project.getProperty("library");
// Create a <fileset dir="" includes=""/>
fs = project.createDataType("fileset");
fs.setDir(new File(dir));
fs.setIncludes("**/*.swf");
fs.setIncludes("**/*.png");
// Get the files (array) of that fileset
ds = fs.getDirectoryScanner(project);
srcFiles = ds.getIncludedFiles();
for (i=0; i<srcFiles.length; i++) {
// get the values via Java API
var basedir = fs.getDir(project);
var filename = srcFiles[i];
// create and use a Task via Ant API
echo = project.createTask("echo");
var id = filename.replace(".","_");
id = id.replace("\\","_");
var file = new File(project.getProperty("library.file"));
echo.setFile(file);
echo.setAppend(true);
echo.setMessage("<clip id=\""+id+"\" import=\""+library+"\\"+filename+"\"/>\n");
echo.perform();
}]]></script>
<echo file="${library.file}" append="true"><![CDATA[
</library>
</frame>
</movie>]]></echo>
<exec executable="${flame.swfmill}">
<arg value="simple"/>
<arg value="library.xml"/>
<arg value="${build}\${flame.mtasc.target}"/>
</exec>
</target>
<target name="documentation">
<mkdir dir="${doc}\html\"/>
<exec executable="${flame.naturaldocs}">
<arg value="-i"/>
<arg value="${src}"/>
<arg value="-o"/>
<arg value="HTML"/>
<arg value="${doc}\html"/>
<arg value="-p"/>
<arg value="${doc}"/>
</exec>
</target>
<target name="compile">
<exec executable="${flame.mtasc}">
<arg value="-cp"/>
<arg value="${src}"/>
<arg value="-swf"/>
<arg value="${build}/${flame.mtasc.target}"/>
<arg value="-main"/>
<arg value="-v"/>
<arg value="${src}/${flame.mtasc.mainclass}"/>
</exec>
</target>
</project>_______________________________________________
osflash mailing list
[email protected]
http://osflash.org/mailman/listinfo/osflash_osflash.org