【问题标题】:Why isn't my standard RSL being loaded?为什么没有加载我的标准 RSL?
【发布时间】:2011-11-15 00:13:50
【问题描述】:

我创建了一个模块化应用程序,其中父 SWF 按需加载许多其他 SWF。为了优化,我创建了一个standard RSL

我已将通用代码编译成 swc,并重新编译应用程序 swfs 以引用此 swc,在我的 build.xml ANT 任务中使用以下内容(对于我的应用程序中的每个 swf):

<static-link-runtime-shared-libraries>false</static-link-runtime-shared-libraries>
<runtime-shared-library-path path-element="${lib.loc}/RSL.swc">
    <url rsl-url="RSL.swf"/>
</runtime-shared-library-path>

我已从 RSL.swc 中提取 RSL.swf,并将其放在我的网络服务器上,与应用程序 swfs 和容器 html 文件位于同一目录中。

现在,当我加载我的应用程序时,我会收到以下消息:

VerifyError: Error #1014: Class mx.core:BitmapAsset could not be found.

我可以看到这个类包含在 RSL.swc / RSL.swf 中的类中。

我使用 fiddler 观察发生了什么,我可以看到我的应用程序 swf 文件已加载,但没有尝试获取 RSL.swf。

将 Application.swf 文件设置为使用 RSL,我预计它会在初始化之前尝试加载 RSL.swf,但是这不会发生。谁能提出原因?

【问题讨论】:

    标签: actionscript ant flash rsl


    【解决方案1】:

    来自http://livedocs.adobe.com/flex/3/html/help.html?content=rsl_02.html

    “如果基类是 Sprite 或 MovieClip,则不能在纯 ActionScript 项目中使用 RSL。RSL 要求应用程序的基类(例如 Application 或 SimpleApplication)了解 RSL 加载。”

    因为我的基类是 Sprite,所以我遇到了这个错误。

    就我而言,最好使用以下步骤将所有必需的类编译到我的应用程序 swf 文件中:

    1. 使用 compc 创建一个 SWC,其中包含我想要包含在我的应用程序 swf 文件中的文件
    2. 将 mxmlc 与指向要包含的 SWC 文件的包含库一起使用。使用链接报告生成链接文件报告 (xml)
    3. 使用指向链接文件报告 (xml) 的 load-externs 编译每个附加的子 swf - 这不包括链接到 Application.swf 的文件被编译到每个子 swf 中

    要实现第 1 步:

    <!-- We define the global classes which will be compiled into the parent Application   
         swf, but excluded from the tool swfs. As pure actionscript projects with base 
         class of Sprite can't usually use RSLs, we are forcing these classes to be loaded 
         into the parent application, and excluded from the child applications, allowing an 
         "Rsl-like" optimisation -->
    
    <fileset id="rsl.inclusions" dir="${main.src.loc}">
        <include name="${main.src.loc}/path1/**/*.as"/>
        <include name="${main.src.loc}/path2/**/*.as"/>
        ...
    </fileset> 
    
    <pathconvert property="rsl.classes" pathsep=" " refid="rsl.inclusions">
    <chainedmapper>
        <globmapper from="${main.src.loc}\*" to="*"/>
            <mapper type="package" from="*.as" to="*"/>
    </chainedmapper> 
    </pathconvert>
    
    <!-- Compile SWC -->
    <compc output="${lib.loc}/MySwc.swc" 
           include-classes="${rsl.classes}">
    <static-link-runtime-shared-libraries>true</static-link-runtime-shared-libraries>   
    <source-path path-element="${main.src.loc}"/>
    </compc>
    

    实现第 2 步:

    <mxmlc file="${main.src.loc}/pathToApp/Application.as" 
       output="${bin.loc}/Application.swf" 
       debug="${debug}"
       use-network="true"
       link-report="WorkbenchLinkReport.xml"
       fork="true">
        <compiler.source-path path-element="${main.src.loc}" />
    <static-link-runtime-shared-libraries>true</static-link-runtime-shared-libraries>
    <include-libraries dir="${lib.loc}" append="true">
        <include name="MySwc.swc" />
    </include-libraries>
    </mxmlc> 
    

    实现第 3 步:

    <mxmlc file="${main.src.loc}/pathToChildSwf1/Child1.as"      
           output="${bin.loc}/Child1.swf" 
           debug="${debug}" 
           load-externs="WorkbenchLinkReport.xml" 
           fork="true">
    <compiler.source-path path-element="${main.src.loc}" />
    <static-link-runtime-shared-libraries>true</static-link-runtime-shared-libraries>
    <compiler.headless-server>true</compiler.headless-server>           
    </mxmlc>
    

    另一个方便的提示:使用 fork="true" 可以防止 Java VM 在编译许多 swf 时耗尽内存。

    希望对您有所帮助!

    【讨论】:

      猜你喜欢
      • 2015-12-24
      • 2012-01-09
      • 1970-01-01
      • 2016-09-16
      • 1970-01-01
      • 1970-01-01
      • 2013-06-16
      • 2018-08-15
      • 2013-02-28
      相关资源
      最近更新 更多