Actionscript 为什么不是';我的标准RSL没有加载吗?

Actionscript 为什么不是';我的标准RSL没有加载吗?,actionscript,ant,flash,rsl,Actionscript,Ant,Flash,Rsl,我已经创建了一个模块化应用程序,其中一个父SWF根据需要加载许多其他SWF。为了优化,我创建了一个 我已将公共代码编译成swc,并在build.xml ANT任务中使用以下命令(对于我应用程序中的每个swf),重新编译应用程序swf以引用此swc: 我可以看到这个类包含在RSL.swc/RSL.swf中的类中 我使用fiddler观察了正在发生的事情,我可以看到我的应用程序swf文件已加载,但没有尝试获取RSL.swf 在将Application.swf文件设置为使用RSLs之后,我希望它在初始

我已经创建了一个模块化应用程序,其中一个父SWF根据需要加载许多其他SWF。为了优化,我创建了一个

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

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

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

在将Application.swf文件设置为使用RSLs之后,我希望它在初始化之前尝试加载RSL.swf,但是这不会发生。有人能提出原因吗?

来自:

如果基类是Sprite或MovieClip,则不能在仅ActionScript项目中使用RSLs。RSLs要求应用程序的基类(如application或SimpleApplication)理解RSL加载

因为我的基类是Sprite,所以我有这个错误

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

  • 使用compc创建一个SWC,其中包含我希望包含在应用程序swf文件中的文件
  • 将mxmlc与指向要包含的SWC文件的包含库一起使用。使用链接报告生成链接文件报告(xml)
  • 使用指向链接文件报告(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虚拟机在编译许多SWF时内存不足

    希望这是有帮助的

    <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> 
    
    <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>