我已经创建了一个模块化的应用程序,其中父SWF按需加载多个其他SWF。为了优化,我创建了一个standard RSL。
我在我的build.xml ANT任务中使用以下代码(对于应用程序中的每个swf ),将常用代码编译到swc中,并重新编译应用程序swf以引用此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,并将其放在我的the服务器上的与应用程序swfs和容器html文件相同的目录中。
现在,当我加载我的应用程序时,我得到这样的消息:
VerifyError: Error #1014: Class mx.core:BitmapAsset could not be found.我可以在RSL.swc / RSL.swf的类中看到这个类。
我已经使用fiddler来观察发生了什么,我可以看到我的应用程序swf文件已经加载,但没有尝试获取RSL.swf。
在将Application.swf文件设置为使用RSL.swf之后,我原本希望它在初始化之前尝试加载RSL,但是这并没有发生。有没有人能告诉我为什么?
发布于 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:
<!-- 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耗尽正在编译的许多swfs的内存。
希望这能对你有所帮助!
https://stackoverflow.com/questions/7382671
复制相似问题