| LowRA API Documentation | Annexes | All Packages | All Classes | Index | Frames |
|
| How to compile IoC DLL file | ||
You will find below the various methods to build DLL file for LowRA IoC.
A dll file is usually compiled to contain a set of objects and using them in an IoC.
These files usually contain class does not inherit Sprite, and usually the entry point of these files do not reference the classes in it.
All informations concerning the Ant tasks directly from the Cédric's blog article
You must be comfortable with the use of Ant Tasks before reading this paragraph.
We will create a set of tasks dedicated to compiling dll.
These tasks will be responsible for :
To compile our dll we need a class that will serve as an entry point to swf.
This class will be automatically generated by the task, so we can ensure that the dll will be compiled, even if the creator of the task did not create an entry point for its dll.
The creation of the temporary file is done simply by an echo of the code of the class in a file with the same name located in the source directory.
In this task property ${tempfile}is the name of the class and ${src} to the directory where the sources of the project.
The use of an external variable to define the name of the class is important, because that enables all these tasks to find the right file.
<target name="dll.CreateTempEntry">
<echo file="${src}/${tempfile}.as">package
{
import flash.display.Sprite;
public class ${tempfile} extends Sprite {}
}
</echo>
</target>
Removing the temporary file now :
<target name="dll.CleanTempEntry">
<delete>
<fileset file="${src}/${tempfile}.as"/>
</delete>
</target>
Now we have to compile this temporary class using your custom compile task.
Here I use the iFac plugin to compile all my swf ( just an example ) :
<target name="fcsh.Compile">
<condition property="includes.arg" value="-includes='${includes}'" else=""> <isset property="includes"/> </condition> <ifac failonerror="true" delay="${iFac.delay}"> <arg value="mxmlc"/> <arg value="-load-config='${flex.config}'"/> <arg value="-source-path+='src'"/> <arg value="-source-path+='${lowra.src}'"/>
<arg value="${includes.arg}"/> <arg value="-output='${output}'"/>
<arg value="'${main}'"/>
</ifac> </target>
Ok now, I have task to create entry point, to remove this entry point and a task to compile my swf.
Creates now a more global task which
call all this three sub task :
<target name="dll.Compile"> <property name="tempfile" value="DLLEntryPoint"/>
<antcall target="dll.CreateTempEntry"> <param name="src" value="${src.dir}"/> <param name="tempfile" value="${tempfile}"/> </antcall>
<antcall target="fcsh.Compile"> <param name="src" value="${src.dir}/${tempfile}.as"/> <param name="output" value="${name}.swf"/> </antcall>
<antcall target="dll.CleanTempEntry"> <param name="src" value="${src.dir}"/> <param name="tempfile" value="${tempfile}"/> </antcall> </target>
Everything is almost done ... it lacks only the class definition to be included in the compilation ( the "include" argument ).
So finally, we will create the task to build a dedicated DLL ( for example, a CSSDesrializer DLL ) :
<target name="dll.Deserializer.compile()">
<antcall target="dll.Compile">
<param name="name" value="CSSDeserializerDll"/>
<param name="bin" value="${bin.dir}"/>
<param name="includes" value="com.bourre.encoding.CSSDeserializer"/>
</antcall>
</target>
And that's all !
You don't know Ant task, and you want to compile dll file using the Flash IDE, no problem.
Create a new Flash document ( Player 9 / ActionScript 3 ).
In the first frame, insert this following ActionScript code :
import com.bourre.encoding.CSSDeserializer; var dll : CSSDesrializer;
Export your swf and that's all ;)
All informations concerning the Ant tasks directly from the Cédric's blog article (thank you sir).
You can find many Ant tasks on
his blog too ( asdoc, <script> node, properties file, and more... )