Apache flex 如何使蚂蚁生成的swf尽可能小?
我有一个flex项目,如果我在我的swf上使用带RSLs的flash builder构建应用程序的发布版本,那么这个版本是115k。但是,如果我使用ant构建相同的应用程序,swf是342k。没有RSLs,swf为52000 如何使swf与FlashBuilder构建的swf一样小 这是我的ant文件,我有另一个复制RSL的任务Apache flex 如何使蚂蚁生成的swf尽可能小?,apache-flex,ant,flex4,mxmlc,Apache Flex,Ant,Flex4,Mxmlc,我有一个flex项目,如果我在我的swf上使用带RSLs的flash builder构建应用程序的发布版本,那么这个版本是115k。但是,如果我使用ant构建相同的应用程序,swf是342k。没有RSLs,swf为52000 如何使swf与FlashBuilder构建的swf一样小 这是我的ant文件,我有另一个复制RSL的任务 <project name="EUI Client Application" default="compileClientApp"> <target
<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>
您可能需要使用-external library path选项指定外部lib的路径 有关更多信息,请参阅 要在编译应用程序时使用RSLs,请使用以下应用程序编译器选项: 使用运行时共享库选项指定应用程序在运行时作为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 ../libraries/CustomDataGrid ../libs/playerglobal.swc ../libraries/CustomCellRenderer/library.swf ../libraries/CustomDataGrid/library.swf 运行时共享库选项是部署应用程序时library.swf文件的相对位置。外部库路径选项是SWC文件或打开目录在编译时的位置。因此,在编译应用程序时,必须知道库相对于应用程序的部署位置。创建库时,您不必知道部署结构,因为您使用compc命令行编译器来创建SWC文件
尝试将您的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>
谢谢各位的回复,但这不是其中任何一个 事实证明,我所需要做的就是删除运行时共享库路径,因为这已经在flex-config.xml文件中了。我还必须将静态链接运行时共享库更改为false(因此它是动态的) 我已经将flex-config.xml文件复制到我的构建目录中,并使用它,以便安全地进行更改 这是与Flex 4顺便说一句-如果我说得很清楚的话 我的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>
使用RSL时,请记住将“使用网络”参数设置为true,否则编译后的swf在不同位置运行时会抱怨安全错误(无法加载RSL)。此项目的Flex/Flash Builder中的编译器参数是什么?
<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>