簡體   English   中英

為什么不加載我的標准RSL?

[英]Why isn't my standard RSL being loaded?

我創建了一個模塊化應用程序,其中父SWF可按需加載許多其他SWF。 為了優化,我創建了一個標准的RSL

我已將通用代碼編譯為swc,並在build.xml ANT任務(針對我的應用程序中的每個swf)中使用以下代碼,將應用程序swfs重新編譯為引用此swc:

<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文件位於同一目錄的Web服務器上。

現在,當我加載我的應用程序時,我收到消息:

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

我可以看到該類包含在RSL.swc / RSL.swf中。

我已經使用提琴手觀察正在發生的事情,並且可以看到我的應用程序swf文件已加載,但是沒有嘗試獲取RSL.swf。

將Application.swf文件設置為使用RSL后,我希望它會在初始化之前嘗試加載RSL.swf,但這不會發生。 有人可以建議原因嗎?

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

“如果基類是Sprite或MovieClip,則不能在僅ActionScript項目中使用RSL。RSL要求應用程序的基類(例如Application或SimpleApplication)了解RSL加載。”

因為我的基類是Sprite,所以出現了此錯誤。

就我而言,最好使用以下步驟將所有必需的類編譯到我的Application swf文件中:

  1. 使用compc使用要包含在我的應用程序swf文件中的文件創建SWC
  2. 將mxmlc與包含庫一起指向要包含的SWC文件。 使用鏈接報告生成鏈接文件報告(xml)
  3. 使用指向鏈接文件報告(xml)的加載外部文件編譯每個其他子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的情況下耗盡內存。

希望這會有所幫助!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM