Using Amfphp 1.9 with the Adobe Flex 2 SDK - Page 4
Apache AntCreating your build fileOpen your text editor and create a new file. Add the line below to the very beginning of the file. This line will identify this file as an XML file. It is very important that no text or whitespace preceed this line. Now save this file as build.xml under your [PROJECT_HOME] directory. <?xml version="1.0" encoding="utf-8"?> Next, we define our project using Ant's project tag. Using the tag's name and basedir attributes we specify a project name and base directory. Setting the basedir attribute to a period indcates that it will use the current directory. The remaining Ant tags we will be defining should be placed inside this project tag. <project name="My Flex App" basedir="."> To use the Flex Ant Task library we must define a task definition. We do this by adding the following task definition tag immediately after are opening project tag. <taskdef resource="flexTasks.tasks"/> After the task definition tag we define some Ant properties that we will be using in our build file. The first and most important property is the FLEX_HOME property. The FLEX_HOME property is required by the Flex Ant Task to locate the Flex compilers. Create a FLEX_HOME property and set its location attribute to the [FLEX_SDK] directory (example: C:\Flex). Create a app.name property and set its value attribute to any name you like. We will refer to this name as [APP_NAME]. The app.name property is used as the zip file name when you distribute your project and it is also passed to the mxmlc compiler as the context-root name. The context-root is used when referencing your Flex application on the URL so it is important that your app.name property not contain any special characters or spaces. We will refer to your server as [SERVER_NAME]. http://[SERVER_NAME]/[APP_NAME] The remaining properties defined are used to provide short-cuts to directories in the [PROJECT_HOME] directory. <property name="FLEX_HOME" location="[FLEX_SDK]"/> Now we define our first target. The clean target will be used to clean-up between builds and distributions. <target name="clean"> The prepare target will prepare the build directory for distribution. It begins by creating the build/${app.name} directory if it does not already exist. It then copies our php source and web directories over to the build/${app.name} directory. <target name="prepare"> The compile target will compile our Main.mxml file using the Flex Ant Task mxmlc tag. The mxmlc tags contains several attributes and subtags that control how Flex will complie our applicaton.
<target name="compile" depends="prepare"> The distribute target will create a zip file of our project for easy distribution. <target name="dist" depends="compile"> The deploy target is optional. I provided it to make project deployment even easier for those using remote servers. If you want to use the FTP task ant provides you must have commons-net-1.4.1.jar and jakarta-oro-2.0.8.jar in the [ANT_HOME]/lib directory. Replace the server attribute with your server. The app.name property in the remotedir attribute must exist prior to running the deploy task. Do not remove the app.name property from the remotedir attribute because your Flex application was compiled using app.name as the context-root. <target name="deploy" depends="compile"> Build,Deploy and Distribute your ProjectRun the following commands from your [PROJECT_HOME] directory. Windows users can use the command-prompt. Linux and Mac users can use the terminal. To compile your project run the compile task. When the compile task has finished executing you will have a directory in your [PROJECT_HOME]/build directory with the name you specified in the app.name property. Copy or ftp the app.name directory to your web server's document root directory. ant compile To deploy your project run the deploy task. This task will ftp the contents of the [PROJECT_HOME]/build directory to your web server's document root directory. ant deploy To distribute your project run the dist task. This task will zip the contents of the [PROJECT_HOME]/build directory. The zip file name will be the one you specified in the app.name property. ant dist Running your ApplicationTesting your PHP servicesBefore running our Flex application we need to test our php services to ensure that are functioning correctly. We can test our php services using the Amfphp services browser. Substitute <context-root> with the value you used for the app.name propery. http://[SERVER_NAME]/[APP_NAME]/amfphp/browser/ Run your Applicationhttp://[SERVER_NAME]/[APP_NAME]/Main.swf
|
Join the discussion.
www.seamlessenterprise.com
IP Convergence
Integrate your wireless and wireline networks.
Learn how from the experts at Sprint.
www.seamlessenterprise.com
Wireless & Wireline Integration
Thoughts, strategies and solutions: join the discussion
www.seamlessenterprise.com
Unified Communications 2009
Join the Discussion. Now.
www.seamlessenterprise.com





print: 
Recent comments
17 hours 24 min ago
18 hours 52 min ago
22 hours 27 min ago
1 day 1 hour ago
1 day 4 hours ago
1 day 4 hours ago
1 day 5 hours ago
1 day 6 hours ago
1 day 7 hours ago
1 day 7 hours ago