Eclipse flex ant coding exampleInside the tutorial, demonstration regarding using
eclipse as an editor for creating flex and ant projects is given. Also,
the coding of flex and apache ant applications and compiling flex
application with ant build.xml file is illustrated very nicely inside the
tutorial. Along with compiling, you will also know how to execute the output file that has extension .swf
with either web browser or adobe flash player, using the ant build.xml
file. Now after all this, download eclipse from eclipse official website that has apache ant
technology as an inbuilt plugin installed. After the download finishes you will get a zip file. That zip file you have
to extract somewhere. Your system C: drive will be best, so extract the
zip file in your c-drive, and after extracting you will get a folder in your
c-drive or in the place where you extracted the zip file. Following shown screen
shots will teach you this.
After dragging and dropping the zip setup file in c-drive extract it
there and after extracting it, a folder with name eclipse will be there in your
c-drive. This step is shown below.
After this open the eclipse folder and double click or open
the eclipse.exe
file. This step shown below.
After opening the eclipse.exe file, following window appears as shown below. After this a window asking for selecting the work space comes. This is shown
below. Here my work space path is C:\baadshah\IDE and i have mark this as my default work space. This is shown below. When the workspace creating process finishes, eclipse
IDE opens. If you want you can also see your work space. Screen shot shown below is my work space folder IDE that contains a folder name .metadata. Now you will be taught to create an ant project and a flex project. For creating the project, first on the welcome window of eclipse click on workbench as shown below.
Now for creating a project go on clicking as directed: File -> new -> project -> general->project or File -> new -> other -> general -> project. After this you will get a window, asking for the project name. Here we will create flex project
first. So write flex in the Project name
column. This project is created on your workspace you selected earlier. Here workspace path
of my project is C:/baadshah/IDE. After creating this flex project you can see a project with name flex is visible on the eclipse Package Explorer and a folder with name flex is created in your workspace.
Now inside this flex project we can now code flex application. So lets start coding flex on eclipse. Right click on your flex project and then switch to new and then switch to file, as shown below.
After this a window opens asking for giving a file name. Here we are going to code a simple flex application to generate a Button, a ComboBox on the Panel background of application. Here i have used file name as rachel with extension mxml. .mxml is the source file extension of flex. After providing the file name with .mxml extension, click on Finish. After this you will get the following window, on this we will code our flex application.
Double click or drag or drop the rachel.mxml file.
I prefer to close the Outline, Problems, Javadoc and Declaration tabs. This will provide you, wide coding space. Also if you want more space, minimize your Package Explorer.
After closing the above mention tabs you will get the
following window.
Now start coding for creating a Button, and ComboBox.
Your code will look like this.
Now for compiling this flex file, flex mxmlc compiler is required, that i told you in the beginning. So i assumed that you have downloaded flex sdk zip file of latest version and extracted in C: drive, as shown below.
Now on eclipse maximize your Package Explorer and select your flex project and right click on it and open a new file by clicking on New and then file.
In New File window go to File name: column and type build.xml. This build.xml is the name of your ant build file.
Now below table is the code provided for the build.xml file so if you want you can copy and paste it in to your build.xml file.
Your build file will look like this.
Let me give you a description about the build.xml
file. This build.xml file is an ant built tool with which here
on eclipse we compile our flex application by calling the flex mxmlc
compiler located in c-drive. To trigger this tool press ctrl
+ f11 or just f11 or right click and
switch to Run As and click
After this a Debug As window comes, in which your have to
select
BUILD SUCCESSFUL means your flex rachel.swf is compiled successfully
and the result output swf file is created in your workspace location as rachel.swf.
Also you can drag and drop your swf file in to Adobe Flash
Player10, as shown below. For this you should have Adobe Flash Player10
Application installed on your system.
Now you can code any number of flex applications in your flex project with eclipse but before deploying the application through ant build.xml file, mention the name of the file inside the build.xml file. Note: Name of the file you are compiling should be mentioned in build.xml file. Illustration of this is shown below. File name rachel.mxml
File name neo.mxml
So you see, name of every new file should be mentioned in the build.xml file. Changing the output swf file name in the build.xml file will make no error so its our choice.
|
» View all related tutorials ![]() |
| Add This Tutorial To: | |||||||
| |
|
|
|
|
|
|
|
|
Home | JSP | EJB | JDBC | Java Servlets | WAP | Free JSP Hosting | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs |
||
Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |
Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.
Copyright © 2008. All rights reserved.