0

親 SWF が他の多数の SWF をオンデマンドでロードするモジュラー アプリケーションを作成しました。最適化のために、標準の RSLを作成しました。

共通コードを swc にコンパイルし、この swc を参照するようにアプリケーション swfs を再コンパイルしました。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 を抽出し、これを Web サーバーのアプリケーションの swfs およびコンテナーの html ファイルと同じディレクトリに配置しました。

アプリケーションをロードすると、次のメッセージが表示されます。

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

このクラスが RSL.swc / RSL.swf のクラスに含まれていることがわかります。

何が起こっているかを観察するためにフィドラーを使用しましたが、アプリケーションの swf ファイルがロードされていることを確認できますが、RSL.swf を取得しようとはしていません。

RSL を使用するように Application.swf ファイルを設定したら、初期化する前に RSL.swf をロードしようとするはずですが、そうはなりません。誰でも理由を提案できますか?

4

1 に答える 1

1

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

「基本クラスが Sprite または MovieClip の場合、ActionScript のみのプロジェクトで RSL を使用することはできません。RSL では、Application や SimpleApplication などのアプリケーションの基本クラスが RSL の読み込みを理解する必要があります。」

私の基本クラスはスプライトだったので、このエラーが発生しました。

私の場合、次の手順を使用して、必要なすべてのクラスをアプリケーションの swf ファイルにコンパイルすることをお勧めします。

  1. compc を使用して、アプリケーションの swf ファイルに含めたいファイルで SWC を作成します
  2. インクルードする SWC ファイルを指す include-libraries で mxmlc を使用します。link-report を使用してリンク ファイル レポート (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>

もう 1 つの便利なヒント: fork="true" を使用すると、多くの swfs がコンパイルされているときに Java VM がメモリ不足になるのを防ぐことができます。

これが役に立てば幸いです!

于 2011-10-03T06:50:00.840 に答える