使用命令行编译as文件成swf
- 设置环境变量到flex sdk的目录下。如:D:\Program Files\Adobe Flash Builder 4.5\sdks\flex_sdk_4.6\bin
-
找到flex-config.xml文件,这个文件在flash builder 安装目录下的sdks/flex_sdk_4.6/frameworks里,复制一份,粘到自己的一个文件夹里(现在我放在d盘下)
- 修改flex-config.xml文件
(1)外面库路径.如果你的工程使用了外部库的.as文件,需要这样改:
<source-path>
<path-element>E:\weiding\work\Client\engine</path-element>
</source-path>
上面的engin主是我的外部类库文件夹
(2)增加swc库路径
在 <library-path>节点下,增加
<path-element>E:\weiding\work\Client\lib</path-element>
lib就是flash builder中引用的swc文件目录
(3)修改相关路径。因为flex-config.xml文件是放在frameworks文件夹里的,现在你把它移出来的,很多相对路径下的文件都找不到了。需要到它们改成绝对路径:
下面是我改好的:
<library-path>
<path-element>D:\Program Files\Adobe Flash Builder 4.5\sdks\flex_sdk_4.6\frameworks\libs</path-element>
<path-element>E:\weiding\work\Client\lib</path-element>
<path-element>D:\Program Files\Adobe Flash Builder 4.5\sdks\flex_sdk_4.6\frameworks/locale/{locale}</path-element>
<!-- The following entry is because LCDS copies playerfds.swc in the player folder -->
<path-element>D:\Program Files\Adobe Flash Builder 4.5\sdks\flex_sdk_4.6\frameworks/libs/player</path-element>
</library-path>
--------------------
<namespace>
<manifest>D:\Program Files\Adobe Flash Builder 4.5\sdks\flex_sdk_4.6\frameworks\mxml-2009-manifest.xml</manifest>
</namespace>
---------
<theme>
<!-- The Flex 4 default theme is Spark. -->
<filename>D:\Program Files\Adobe Flash Builder 4.5\sdks\flex_sdk_4.6\frameworks/themes/Spark/spark.css</filename>
</theme>
----------
<external-library-path>
<path-element>D:\Program Files\Adobe Flash Builder 4.5\sdks\flex_sdk_4.6\frameworks/libs/player/{targetPlayerMajorVersion}.{targetPlayerMinorVersion}/playerglobal.swc</path-element>
</external-library-path>
-------------
-
取消运行时共享库:
<static-link-runtime-shared-libraries>true</static-link-runtime-shared-libraries>
(原来是false)
-
开始编译
cmd输入:
mxmlc -load-config d:\flex-config.xml E:/weiding/work/Client/src/Main.as -output C:\wamp\www\client\Main.swf
这样就完成了