5

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

如何让 swf 与 FlashBuilder 构建的一样小?

这是我的 ant 文件,我还有另一个复制 rsls 的任务。

<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

4 回答 4

2

谢谢大家的回复,但不是其中任何一个。

原来我需要做的就是删除 runtime-shared-library-path 的东西,因为它已经在 flex-config.xml 文件中了。我还必须将 static-link-runtime-shared-libraries 更改为 false(因此它是动态的)。

我已将 flex-config.xml 文件复制到我的构建目录并使用它,以便我可以安全地进行更改。

顺便说一句,这是 Flex 4 - nto 确定我是否说得很清楚。

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

于 2009-08-07T10:31:10.060 回答
1

您可能需要使用-external-library-path选项指定外部库的路径。

有关更多信息,请参阅文档

要在编译应用程序时使用 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.

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

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

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

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

mxmlc -runtime-shared-libraries= ../libraries/CustomCellRenderer/library.swf, ../libraries/CustomDataGrid/library.swf -external-library-path=../libraries/CustomCellRenderer, ../libraries/CustomDataGrid MyApp .mxml

库的顺序很重要,因为必须在使用它们的类之前加载基类。

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

../libraries/CustomCellRenderer ../libraries/CustomDataGrid ../libs/playerglobal.swc ../libraries/CustomCellRenderer/library.swf ../libraries/CustomDataGrid/library.swf

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

于 2009-08-06T13:36:49.553 回答
1

尝试将您的 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>
于 2009-08-06T13:42:56.270 回答
0

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

于 2010-07-07T06:14:20.087 回答