首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么我的标准RSL没有被加载?

为什么我的标准RSL没有被加载?
EN

Stack Overflow用户
提问于 2011-09-12 10:03:40
回答 1查看 889关注 0票数 0

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

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

代码语言:javascript
复制
<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,并将其放在我的the服务器上的与应用程序swfs和容器html文件相同的目录中。

现在,当我加载我的应用程序时,我得到这样的消息:

代码语言:javascript
复制
VerifyError: Error #1014: Class mx.core:BitmapAsset could not be found.

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

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

在将Application.swf文件设置为使用RSL.swf之后,我原本希望它在初始化之前尝试加载RSL,但是这并没有发生。有没有人能告诉我为什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-10-03 14:50:01

来自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文件的include-libraries一起使用。使用加载每个附加子swf生成链接文件报告(xml),加载扩展名指向链接文件报告(xml) -这将排除链接到Application.swf的文件,使其不会编译到每个子swf

要实现步骤1:

代码语言:javascript
复制
<!-- 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:

代码语言:javascript
复制
<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:

代码语言:javascript
复制
<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耗尽正在编译的许多swfs的内存。

希望这能对你有所帮助!

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7382671

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档