3

I'm trying to build a flex project, linking it to some RLSs. When setting up the project in Flex Builder, the corresponding "build configuration" (that I got by adding -dump-config to the compiler options) generates (among other things) a tag like this :

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

Now, I am trying to build the project using mxmlc ant task, but I can't seem to add any reference to a share-library. I thought something like this would have help, but it didin't:

<!-- 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>

So what could I be missing here ?

Thanks

phtrivier
  • 13,047
  • 6
  • 48
  • 79

3 Answers3

9

You will need to specify the path to the SWC of your custom libraries via the "path-element" attribute on the "runtime-shared-library-path" element and define the "rsl-url" in the "url" element which points to the SWF. Note that this is needed for each custom RSL individually.

To achieve this you'll need to unpack the SWC and extract the SWF from it so that the compiler can copy it to the output folder.

There is a comment on a post here that describes how to include the Mate framework as an RSL. I added the interesting part below.

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>
Christophe Herreman
  • 15,895
  • 9
  • 58
  • 86
  • I'll try that, thanks. However, does it mean that in practice Flash Builder does this "unzipping the swc - making an swf out of it - compiling against the swc and specifying the swf url for runtime" under the hood ? (I'm trying to understand why ant has to go through all this ...) – phtrivier Feb 15 '11 at 14:11
  • Yes, Flash Builder is able to do that for you. Check http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf674ba-7ff6.html Quote: "You can have Flash Builder extract the RSL’s SWF file from the SWC file automatically or you can do it manually. Deselect the Auto Extract swf to Deployment Path option if you want to extract the RSL’s SWF file from the SWC file manually. Otherwise, Flash Builder will extract the SWF file for you. In general, you should manually extract the SWF file and optimize it before deploying it. Otherwise, the library.swf file will be larger than necessary." – Christophe Herreman Feb 15 '11 at 14:15
1

I guess you are missing the path-element

        <runtime-shared-library-path path-element="${FLEX_FRAMEWORK}/framework.swc">
            <url rsl-url="framework_3.4.1.10084.swf"/>
            <!--<url rsl-url="datavisualization_3.2.0.3958.swf"/>-->
        </runtime-shared-library-path>
kbgn
  • 856
  • 1
  • 7
  • 16
  • 1
    This only seems to add elements to the "" section of the config (which is logical in a sense). This is what I would use for framework RSL ; in my situation I want to add reference to RSL that *I* am compiling (and Flex Builder adds it to the section of the config, so I am naively trying to do that as well...) – phtrivier Feb 10 '11 at 09:04
0

You may find this xsl useful. You can call it from ant and generate your RSL entries from you .actionScriptProperties file. I hope this helps everyone going through RSL hell!!! See here:

    <mxmlc output="${{dist.dir}}/${{inputMXML}}.swf"
                    file="${{src.dir}}/${{inputMXML}}.mxml"
                    locale="${{compiler.locale}}"
                    use-network="${{compiler.use-network}}"
                    debug="false"
                    optimize="true"
                    incremental="false">
                 <load-config filename="${{FLEX_HOME}}/frameworks/flex-config.xml"/>

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

                 <!-- Project RSLs -->
            <xsl:for-each select="//libraryPath/libraryPathEntry">
                 <xsl:if test="@linkType = '1'">
           <compiler.library-path>
                 <!--  substring before last '/' -->
                 <xsl:attribute name="dir">
                        <xsl:call-template name="substring-before-last">
                                     <xsl:with-param name="list" select="@path" />
                                     <xsl:with-param name="delimiter" select="'/'" />
                              </xsl:call-template>
                 </xsl:attribute>
                 <xsl:attribute name="append">true</xsl:attribute>
                       <xsl:element name="include">
                              <xsl:attribute name="name">
                                            <!--  substring after last '/' -->
                                            <xsl:call-template name="substring-after-last">
                                              <xsl:with-param name="string" select="@path" />
                                              <xsl:with-param name="delimiter" select="'/'" />
                                            </xsl:call-template>
                              </xsl:attribute>
                       </xsl:element>
           </compiler.library-path>
                 </xsl:if>
         </xsl:for-each>



                 <!-- Framework RSLs. Note: Order is important. Also note: swz comes
                      first. This is the signed version of the library which once
                      downloaded can be used cross-domain, possibly saving bandwidth -->
                 <runtime-shared-library-path path-element="${{FLEX_HOME}}/frameworks/libs/textLayout.swc">
                       <url rsl-url="textLayout_2.0.0.232.swz"/>
                       <url rsl-url="textLayout_2.0.0.232.swf"/>
                 </runtime-shared-library-path>
                 <runtime-shared-library-path path-element="${{FLEX_HOME}}/frameworks/libs/framework.swc">
                       <url rsl-url="framework_4.6.0.23201.swz"/>
                       <url rsl-url="framework_4.6.0.23201.swf"/>
                 </runtime-shared-library-path>
                 <runtime-shared-library-path path-element="${{FLEX_HOME}}/frameworks/libs/osmf.swc">
                       <url rsl-url="osmf_1.0.0.16316.swz"/>
                       <url rsl-url="osmf_1.0.0.16316.swf"/>

                 </runtime-shared-library-path>
                 <runtime-shared-library-path path-element="${{FLEX_HOME}}/frameworks/libs/charts.swc">
                       <url rsl-url="charts_4.6.0.23201.swz"/>
                       <url rsl-url="charts_4.6.0.23201.swf"/>
                 </runtime-shared-library-path>
                 <runtime-shared-library-path path-element="${{FLEX_HOME}}/frameworks/libs/rpc.swc">
                       <url rsl-url="rpc_4.6.0.23201.swz"/>
                       <url rsl-url="rpc_4.6.0.23201.swf"/>
                 </runtime-shared-library-path>
                 <runtime-shared-library-path path-element="${{FLEX_HOME}}/frameworks/libs/mx/mx.swc">
                       <url rsl-url="mx_4.6.0.23201.swz"/>
                       <url rsl-url="mx_4.6.0.23201.swf"/>
                 </runtime-shared-library-path>
                 <runtime-shared-library-path path-element="${{FLEX_HOME}}/frameworks/libs/spark.swc">
                       <url rsl-url="spark_4.6.0.23201.swz"/>
                       <url rsl-url="spark_4.6.0.23201.swf"/>
                 </runtime-shared-library-path>
                 <runtime-shared-library-path path-element="${{FLEX_HOME}}/frameworks/libs/advancedgrids.swc">
                       <url rsl-url="advancedgrids_4.6.0.23201.swz"/>
                       <url rsl-url="advancedgrids_4.6.0.23201.swf"/>
                 </runtime-shared-library-path>
                 <runtime-shared-library-path path-element="${{FLEX_HOME}}/frameworks/libs/sparkskins.swc">
                       <url rsl-url="sparkskins_4.6.0.23201.swz"/>
                       <url rsl-url="sparkskins_4.6.0.23201.swf"/>
                 </runtime-shared-library-path>
                 <runtime-shared-library-path path-element="${{FLEX_HOME}}/frameworks/libs/spark_dmv.swc">
                       <url rsl-url="spark_dmv_4.6.0.23201.swz"/>
                       <url rsl-url="spark_dmv_4.6.0.23201.swf"/>
                 </runtime-shared-library-path>

                 <!-- Project RSLs -->
                 <!-- Flex Ant Task Shortcoming. -->
                 <xsl:for-each select="//libraryPath/libraryPathEntry">
                 <xsl:if test="@linkType = '4'">
                         <runtime-shared-library-path>
                               <xsl:attribute name="path-element">
                                      <xsl:value-of select="@path" />
                               </xsl:attribute>
                       <xsl:element name="url">
                              <xsl:attribute name="rsl-url">
                                    <xsl:value-of select="crossDomainRsls/crossDomainRslEntry/@rslUrl" />
                              </xsl:attribute>
                       </xsl:element>
                         </runtime-shared-library-path>
                 </xsl:if>
         </xsl:for-each>
    </mxmlc>