Flex Ant Tasks - Step by Step
1. You should have Eclipse installed in your machine. In case you do not have Eclipse, download from http://www.eclipse.org. Uncompress it and keep in c:/eclipse.
2. You should also have Flex in your computer. In case Flex is not there, Download Flex plugin for eclipse and install it. You can download trial version of Flex from http://www.adobe.com/products/flex/.
3. Download Ant. Uncompress it and keep in c:/ant.
4. Download Flex Ant Tasks zip from http://labs.adobe.com/wiki/index.php/Flex_Ant_Tasks. Ucompress it and keep in c:/flex_ant_tasks.
5. Copy flexTasks.jar from c:/flexAntTasks into c:/ant.
5. Ant classpath: Go to Window > Preferences > Ant > Runtime > Classpath > Global Entries.
6. Click 'Global Entries'.
7. Click 'Add External jars'. Add C:\ant\lib\flexTasks.jar.
8. You may get below error message popup. Click No. We will take care of the error message in the next step.
9. tools.jar: Click 'Add External jars'. Browse to JDK directory in your machine. In my machine it was at C:\Program Files\Java\jdk1.6.0_03\lib\tools.jar.
10. Click 'Tasks' tab. As shown in the below snapshot, give the name 'mxmlc'. Select flexTasks.jar in the Dropdown. In my case, as per point 3 above, I selected C:\ant\lib\flexTasks.jar.
11. Expand the directory structure as abolve - /flex2/ant.
12. Select MxmlcTask.class. Click OK. Click OK.
13. Flex Project: Create a new Flex project. Name it FlexProject.
14. If you followed point 4 above, go to c:/flex_ant_tasks and copy flexTasks.tasks into the root of your project (FlexProject in the example).
15. Build.xml: Create build.xml file in the root of the folder. Add below code into this file.
<project name="FlexProject" default="main" basedir=".">
<property name="FLEX_HOME" value="C:/Program Files/Adobe/Flex Builder 3 Plug-in/sdks/3.0.0"/>
<property name="PROJECT_HOME" value="D:/grvgl/workspace/FlexProject"/>
<property name="MAIN_SOURCE_FOLDER" value="${PROJECT_HOME}/src/"/>
<echo message = "${MAIN_SOURCE_FOLDER}"/>
<property name="OUTPUT_FOLDER" value="${PROJECT_HOME}/bin"/>
<target name="main">
<mxmlc file="${MAIN_SOURCE_FOLDER}/FlexProject.mxml" output="${OUTPUT_FOLDER}/FlexProject.swf" keep-generated-actionscript="true">
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<source-path path-element="${MAIN_SOURCE_FOLDER}"/>
</mxmlc>
</target>
</project>
16. You will need to modify build.xml as below.
16.1 Update the path for "FLEX_HOME" to point to the folder having bin directory of Flex Builder in your machine.
16.2 If you chose a different name for your project, find replace 'FlexProject' with the name of your project. Use the name of your project wherever further steps refer to FlexProject. 'FlexProject' was the name of project created in this example.
17. Configuring Ant tasks is done now. Let do the 'Hello World!'. Open file src/FlexProject.mxml.
18. Copy below code into FlexProject.mxml.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Label text="Hello World!" horizontalCenter="0" verticalCenter="0"/>
</mx:Application>
19. Run build.xml.
You should now be able to see the output in the swf generated in /bin/FlexProject.swf.





- Facebook Like
- Google Plus One
- Log in or register to post comments
