0

ColdFusion Flash Forms To Flex 2

Flex 2
I'll start off by saying that when Macromedia (when they were still Macromedia) released CFMX 7, it was truly amazing. CFMX 7 has a feature set that I have not seen another application server come close to matching; Flash forms, pdf generation, XForms, gateways, and the list goes on. What was equally amazing was the extent to which the CF community took these features and ran with them. The ASFusion group did things with Flash forms people thought were impossible. Todd, at cfsilence.com developed a data source browser, called Genesis, that connects to your CF server and allowed you to run SQL against the data sources. All these things have really helped push ColdFusion as a valuable resource for web application development. Now Adobe, since aquiring Macromedia, has gone and done it again by releasing the Flex 2 SDK for free. The demos are insane and whats more is that now every website, running ColdFusion or not, can have rich Flash content - that cool admin control panel, or the great shopping cart.

So with all the giving from Adobe and the CF community going around I decided to post the Ant build script I wrote for automatically compiling Flex 2 applications from within Eclipse.

To use the script:

  1. copy the source into a build.xml file in your project folder
  2. edit the properties at the top of the file to point to your sdk install directory, debug flash player, the input mxml file and the output swf file
  3. right click the file and choose "Run As" > "External Tools"
  4. create two new "Ant Build" configurations, one called "build" and the other called "run"
  5. now in the targets tab of the build configuration make sure only the build target is checked
  6. in the targets tab of the run configuration make sure only the run target is checked

Once the setup is done you can run the build commands using the 'Alt+Shift+x q' shortcut.

 <?xml version="1.0"?>
<project name="Flex2 build script" default="build" basedir=".">
   <property name="installdir" value="/Flex2SDK"/>
   <property name="libdir" value="${installdir}/lib"/>
   <property name="mxmlc" value="${libdir}/mxmlc.jar"/>
   
   <property name="src" location="customer.mxml"/>
   <property name="swf" location="customer.swf"/>
   <property name="player" location="${installdir}/player/debug/SAFlashPlayer.exe"/>
   
   <target name="init">
   </target>
   
   <target name="build" depends="init">
      <antcall target="compile"/>
   </target>
   
   <target name="compile">
      <java jar="${mxmlc}" fork="true" failonerror="true">
         <classpath>
            <fileset dir="${libdir}">
               <include name="**/*.jar"/>
            </fileset>
         </classpath>
         <jvmarg value="-Dapplication.home=${installdir}"/>
         <jvmarg value="-ea"/>
         <jvmarg value="-DAS3"/>
         <jvmarg value="-DAVMPLUS"/>
         <jvmarg value="-Xms32m"/>
         <jvmarg value="-Xmx756m"/>
         <jvmarg value="-Dsun.io.useCanonCaches=false"/>
         <arg value="-incremental"/>
         <arg file="${src}"/>
      </java>
   </target>
   
   <target name="run">
      <exec executable="${player}" dir="${basedir}" spawn="true">
         <arg value="${swf}"/>
      </exec>
   </target>
   
</project>

tags:
Flex 2

Search