代码之家  ›  专栏  ›  技术社区  ›  Roaders

如何使我的蚂蚁生成的SWF尽可能小?

  •  5
  • Roaders  · 技术社区  · 16 年前

    我有一个flex项目,如果我使用flash builder构建一个应用程序的版本,在我的swf上rsls是115k。但是如果我使用ant构建相同的应用程序,swf是342k。没有rsls,swf是520k。

    如何让SWF像FlashBuilder构建的那样小?

    这是我的Ant文件,我还有一个复制RSL的任务。

    <project name="EUI Client Application" default="compileClientApp">
    
    <target name="compileClientApp" depends="compileClientBundles">
        <mxmlc 
            file="${CLIENT_PROJECT.dir}/src/${CLIENT_PROJECT.app}.mxml" 
            output="${DEPLOY.dir}/${CLIENT_PROJECT.app}.swf" 
            keep-generated-actionscript="false" 
            actionscript-file-encoding="UTF-8" 
            incremental="false"
            >
    
            <runtime-shared-library-path path-element="${FLEX_HOME}/frameworks/libs/framework.swc">
                <url rsl-url="flex4_4.0.0.7791.swf"/>
                <url rsl-url="framework_4.0.0.7791.swf"/>
                <url rsl-url="framework_textLayout_4.0.0.7791.swf"/>
                <url rsl-url="rpc_4.0.0.7791.swf"/>
                <url rsl-url="textLayout_451.swf"/>
            </runtime-shared-library-path>
    
            <source-path path-element="${CLIENT_PROJECT.dir}/src" />
    
            <compiler.library-path dir="${LIBS.dir}" append="true">
                <include name="*.swc" />
            </compiler.library-path>
            <compiler.library-path dir="${DEPLOY_BIN.dir}" append="true">
                <include name="*.swc" />
            </compiler.library-path>
    
        </mxmlc>
    </target>
    
    <target name="generateWrapper">
        <html-wrapper 
            title="${CLIENT_APP_TITLE}" 
            file="${CLIENT_PROJECT.app}.html" 
            height="100%" width="100%" 
            bgcolor="white" application="app" 
            swf="${CLIENT_PROJECT.app}" 
            version-major="10" version-minor="0" version-revision="0" 
            history="true" output="${DEPLOY.dir}" />
    </target>
    
    <target name="compileClientBundles">
        <compileBundle bundleName="Modules" source="${CORE_PROJECT.dir}/locale" />
    </target>
    

    4 回复  |  直到 14 年前
        1
  •  2
  •   Roaders    16 年前

    谢谢你们的回复,但这两者都不是。

    结果我只需要删除运行时共享库路径的内容,因为它已经在flex-config.xml文件中了。我还必须将静态链接运行时共享库更改为false(所以它是动态的)。

    我已经将flex-config.xml文件复制到我的build目录中并使用它,这样我就可以安全地进行更改。

    这是与灵活4 btw-确定如果我说得很清楚。

    我的Ant文件现在看起来如下:

    <project name="EUI Client Application" default="compileClientApp">
    
    <target name="compileClientApp" depends="compileClientBundles">
        <mxmlc 
            file="${CLIENT_PROJECT.dir}/src/${CLIENT_PROJECT.app}.mxml" 
            output="${DEPLOY.dir}/${CLIENT_PROJECT.app}.swf" 
            keep-generated-actionscript="false" 
            actionscript-file-encoding="UTF-8" 
            optimize="true" incremental="false"
            link-report="${DEPLOY_BIN.dir}/app_link_report.xml"
            >
    
            <load-config filename="${basedir}/flex-config.xml" />
    
            <define name="CONFIG::stub" value="false" />
            <define name="CONFIG::release" value="true" />
    
            <source-path path-element="${CLIENT_PROJECT.dir}/src" />
    
            <compiler.library-path dir="${LIBS.dir}" append="true">
                <include name="*.swc" />
            </compiler.library-path>
            <compiler.library-path dir="${DEPLOY_BIN.dir}" append="true">
                <include name="*.swc" />
            </compiler.library-path>
        </mxmlc>
    </target>
    
    <target name="generateWrapper">
        <html-wrapper 
            title="${CLIENT_APP_TITLE}" 
            file="${CLIENT_PROJECT.app}.html" 
            height="100%" width="100%" 
            bgcolor="white" application="app" 
            swf="${CLIENT_PROJECT.app}" 
            version-major="10" version-minor="0" version-revision="0" 
            history="true" output="${DEPLOY.dir}" />
    </target>
    
    <target name="compileClientBundles">
        <compileBundle bundleName="Modules" source="${CORE_PROJECT.dir}/locale" />
    </target>
    

        2
  •  1
  •   Christophe Herreman    16 年前

    您可能需要使用 -外部库路径 选择权。

    the docs 更多信息。

    要在编译应用程序时使用RSL,请使用以下应用程序编译器选项:

    * runtime-shared-libraries Provides the run-time location of the shared library.
    * external-library-path|externs|load-externs Provides the compile-time location of the libraries. The compiler requires this for dynamic linking.
    

    使用运行时共享库选项指定应用程序在运行时作为RSL加载的SWF文件的位置。指定SWF文件相对于应用程序部署位置的位置。例如,如果将library.swf文件存储在Web服务器的web_root/libraries目录中,并将应用程序存储在web根目录中,则指定libraries/library.swf。

    可以使用此选项指定一个或多个库。如果指定了多个库,请用逗号分隔每个库。

    使用外部库路径选项指定库的SWC文件或应用程序在编译时引用的打开目录的位置。编译器使用此选项指定的库提供编译时链接检查。还可以使用externs或load externs选项指定单个类或定义库内容的XML文件。

    以下命令行示例编译使用两个库的myapp应用程序:

    MXMLC-运行时共享库= ../libraries/customcellrenderer/library.swf, ../libraries/customdatagrid/library.swf -外部库路径=../libraries/customcellrenderer, ../libraries/customdatagrid myapp.mxml

    库的顺序很重要,因为必须先加载基类,然后再加载使用它们的类。

    您还可以使用配置文件,如下示例所示:

    ../libraries/customcellrenderer(库/customcellrenderer) ../libraries/customdatagrid ../libs/playerglobal.swc ../libraries/customcellrenderer/library.swf ../libraries/customdatagrid/library.swf

    运行时共享库选项是应用程序部署后library.swf文件的相对位置。外部库路径选项是编译时SWC文件或打开目录的位置。因此,在编译应用程序时,必须知道库相对于应用程序的部署位置。创建库时不必知道部署结构,因为您使用compc命令行编译器创建SWC文件。

        3
  •  1
  •   DyreSchlock    16 年前

    试着把你的RSL分成他们自己的论点。以下是我的体形:

    <runtime-shared-library-path path-element="${FLEX_HOME}/frameworks/libs/framework.swc">
        <url rsl-url="${rsl.url}/framework_3.2.0.3958.swz" />
        <url rsl-url="${rsl.url}/framework_3.2.0.3958.swf" />
    </runtime-shared-library-path>
    
    <runtime-shared-library-path path-element="${FLEX_HOME}/frameworks/libs/datavisualization.swc">
        <url rsl-url="${rsl.url}/datavisualization_3.2.0.3958.swz" />
        <url rsl-url="${rsl.url}/datavisualization_3.2.0.3958.swf" />
    </runtime-shared-library-path>
    
        4
  •  0
  •   Gnought    16 年前

    使用rsl时,记住将use network参数设置为true,否则编译后的swf在不同位置运行时会抱怨安全错误(无法加载rsl)。