使用ant mxmlc任务将runtime-library-path添加到flex构建配置

pht*_*ier 3 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>
Run Code Online (Sandbox Code Playgroud)

现在,我正在尝试使用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>
Run Code Online (Sandbox Code Playgroud)

那么我在这里可以缺少什么呢?

谢谢

Chr*_*man 9

您需要通过"runtime-shared-library-path"元素上的"path-element"属性指定自定义库的SWC的路径,并在"url"元素中定义"rsl-url"到SWF.请注意,每个自定义RSL都需要单独使用.

为此,您需要解压缩SWC并从中提取SWF,以便编译器可以将其复制到输出文件夹.

有一则讯息的评论在这里,描述了如何包括伴侣框架的RSL.我在下面添加了有趣的部分.

首先,您必须自己从SWC文件中提取SWF.

<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>
Run Code Online (Sandbox Code Playgroud)

然后,您需要将此SWF文件作为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>
Run Code Online (Sandbox Code Playgroud)