apache-flex - 使用 ant mxmlc 任务将运行时库路径添加到 Flex 构建配置

标签 apache-flex ant mxmlc

我正在尝试构建一个 Flex 项目,并将其链接到一些 RLS。在 Flex Builder 中设置项目时,相应的“构建配置”(我通过将 -dump-config 添加到编译器选项而获得)会生成(除其他外)如下所示的标签:

<runtime-shared-libraries>
  <url>some-lib.swf</url>
  <url>some-other-lib.swf</url>
</runtime-shared-libraries>

现在,我正在尝试使用 mxmlc ant 任务构建项目,但我似乎无法添加对共享库的任何引用。我以为这样的东西会有所帮助,但事实并非如此:

<!-- Skipping attributes that I don't think are relevant ... -->
<mxmlc ....>
 ...
 <runtime-shared-library-path>
<url rsl-url="some-lib.swf"></url>
<url rsl-url="some-other-lib.swf"></url>
 </runtime-shared-library-path>
</mxmlc>

那么我在这里可能会错过什么?

谢谢

最佳答案

您需要通过“runtime-shared-library-path”元素上的“path-element”属性指定自定义库的 SWC 路径,并在“url”中定义“rsl-url”指向 SWF 的元素。请注意,每个自定义 RSL 都需要这样做。

要实现此目的,您需要解压 SWC 并从中提取 SWF,以便编译器可以将其复制到输出文件夹。

帖子有评论here描述如何将 Mate 框架包含为 RSL。我添加了下面有趣的部分。

First, you have to extract the SWF from the SWC file yourself.

<macrodef name="create-rsl">
  <attribute name="rsl-dir" />
  <attribute name="swc-dir" />
  <attribute name="swc-name" />
  <sequential>
    <unzip src="@{swc-dir}/@{swc-name}.swc" dest="@{rsl-dir}" >
      <patternset>
        <include name="library.swf" />
      </patternset>
    </unzip>
    <move file="@{rsl-dir}/library.swf" tofile="@{rsl-dir}/@{swc-name}.swf"/>
  </sequential>
</macrodef>

<target name="extract-rsls">
  <!-- Third parties RSLs -->
  <create-rsl rsl-dir="${build.rsls.dir}" swc-dir="${lib.dir}" swc-name="mate" />
</target>

Then, you need to put this SWF file as a RSL:

<target name="compile">
  <mxmlc file="${src.dir}/MyApplication.mxml" output="${build.dir}/MyApplication.swf" locale="${locale}" debug="false">
    <!-- Flex default compile configuration -->
    <load-config filename="${flex.frameworks.dir}/flex-config.xml" />

    <!-- Main source path -->
    <source-path path-element="${src.dir}" />

    <runtime-shared-library-path path-element="${lib.dir}/mate.swc">
      <url rsl-url="rsls/mate.swf" />
    </runtime-shared-library-path>
  </mxmlc>
</target>

关于apache-flex - 使用 ant mxmlc 任务将运行时库路径添加到 Flex 构建配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4948403/

相关文章:

java - 使用 build.xml 从源文件夹创建一个 jar 文件

actionscript-3 - Flex 条件编译错误

apache-flex - 没有 Flex 框架/组件的 MXML

apache-flex - 如何使FlashBuilder向我显示命令行输出?

apache-flex - Flex 中的相反代码

actionscript-3 - 无需过渡即可更改 View

multithreading - AS3使用工作线程调用另一个swf文件中的方法

apache-flex - Spark List 中的项目 Change Effect 等价物是什么?

svn - 如何使用ant获取最后一次svn提交的用户名?

java - 有什么好的工具可以查看和浏览ant build文件吗?