在官方网站adobe上可以下载到编写Flex程序的基本工具,首先我们还是运用text的方式来开发我们的第一个程序,并且建议运用Ant工具来部署运行我们的程序。具体情况如下:
设置环境变量path=D:/FreeFlex/sdks/3.2.0/bin
文件名称:mxmlc HelloWorld.mxml
mxmlc -keep-generated-actionscript HelloWorld.mxml
上述直接用手动的去部署,只有一个文件的时候,还可以。但如果你的工程有上百个呢?会很麻烦,我们还是用Ant这个工具吧。
即使是一个很简单的工程,比如HelloWorld.mxml文件,也应该严格遵照如下的步骤:
1.用mxmlc编译器把HelloWorld.mxml文件编译为.swf文件
2.创建一个HTML文件包
3.创建一个HelloWorld将要发布到WEB服务器上的路径
4.然后把.swf文件拷贝到第3步所创建的路径
用ant语言规范把上述的步骤实施如下:
<project name="HelloWorld" default="compile">
<property name="flex.mxmlc" location="D:/FreeFlex/sdks/3.2.0/bin/mxmlc.exe"/>
<property name="dest.dir" value="bin"/>
<target name="init">
<delete dir="${dest.dir}"/>
<mkdir dir="${dest.dir}"/>
<attrib file="${dest.dir}"/>
</target>
<target name="compile" depends="init">
<exec executable="${flex.mxmlc}" failonerror="true">
<arg line="-output '${dest.dir}/HelloWorld.swf'"/>
<arg line="HelloWorld.mxml"/>
</exec>
</target>
</project>
运用Ant来构建我们需要的build.xml文件即可.
C:/Documents and Settings/Administrator/桌面/Flex3MDmodel/FlexPractice1>ant
Buildfile: build.xml
init:
[delete] Deleting directory C:/Documents and Settings/Administrator/桌面/Flex
3/CMD model/FlexPractice1/bin
[mkdir] Created dir: C:/Documents and Settings/Administrator/桌面/Flex3CMD
model/FlexPractice1/bin
compile:
[exec] Loading configuration file D:/FreeFlex/sdks/3.2.0/frameworks/flex-co
nfig.xml
[exec] C:/Documents and Settings/Administrator/桌面/Flex3/CMD model/FlexPra
ctice1/bin/HelloWorld.swf (174647 bytes)
BUILD SUCCESSFUL
Total time: 8 seconds
实际与直接使用:mxmlc -output bin/HelloWorld.swf HelloWorld.mxml效果相同。
但是接下来其他的工作就是你只用编码即可,然后在CMD中直接运行ant就可以看到程序运行的效果了。