使用多个模块时优化 Flex [英] Optimizing Flex when multiple modules are used

查看:26
本文介绍了使用多个模块时优化 Flex的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Flex 应用程序,其中加载时间非常重要(消费者站点).我希望能够在屏幕上显示一些内容,然后根据需要允许加载其他模块.

I have a Flex application where load time is extremely important (consumer site). i want to be able to get something up on screen and then allow additional modules to be loaded as necessary.

我面临的问题是,所有模块的总和比将所有组件包含在一个 .swf 文件中要大得多.

The issue I'm facing is that the sum total of all the modules is much larger than if i were to include all the components in a single .swf file.

原因很明显.例如,访问 Web 服务所需的类似乎需要大约 100kb.如果我不在 main.swf 中使用这些类,那么它们将包含在使用它们的每个模块中.所以如果我有 5 个模块,那就浪费了额外的 500kB.

Its pretty obvious why. For instance the classes needed for web service access seem to take about 100kb. If I dont use those classes in my main.swf then they'll be included in EVERY module that uses them. So if I have 5 modules thats an extra 500kB wasted.

理论上我想要 3 个级别

In theory I want 3 levels

main.swf - 最小可能的布局/样式/字体/框架类型的东西common.swf - 模块 1 + 模块 2 所需的附加类(例如 Web 服务)module1.swf - 站点中的模块 1module2.swf - 站点中的模块 2

main.swf - minimum possible layout / style / font / framework type stuff common.swf - additional classes needed by module 1 + module 2 (such as web services) module1.swf - module 1 in site module2.swf - module 2 in site

我不知道这是否可能.

我想知道是否可以为框架的一部分而不是整个框架加载 swz/swf 文件.

I'm wondering if I can load swz/swf files for portions of the framework instead of the entire framework.

我真的需要将我的主应用程序大小降低到 200Kb.当我添加 Web 服务和基本的数据网格功能时,它会增长到 450kb.

I really need to get my main app size down to 200Kb. It grows to 450kb when I add web services and basic datagrid functionality.

任何经验教训将不胜感激.

Any lessons learned would be appreciated.

推荐答案

我知道这是前一段时间,但我想我会发布另一个回复,以防有人仍在寻找答案.

I know this was awhile ago, but I figured I'd post another response in case anyone is still looking for an answer on this.

我一直在研究优化 Flex 应用程序,经过一番检查后,我决定使用模块.主要是因为他们有很好的优化选项.

I've been looking into optimizing Flex apps and, after some checking into it, have decided to use Modules. Primarily 'cause they have such good options for optimization.

您需要的两个 mxmlc 命令是:

The two mxmlc commands you need are:

mxmlc -link-report=MyAppReport.xml MyApp.mxml

mxmlc -load-externs=MyAppReport.xml MyModule.mxml

我的外部 swf(使用 Flex 框架)现在只有 21k.它做了很多(目前),但即使它做的越来越多,它仍将继续使用主应用代码中的资源.

My external swf (using the Flex Framework) is now only 21k. It's doing much (yet), but even as it does more and more, it will continue to use resources from the main app code.

这是我为加快进程而创建的批处理文件(您必须将 mxmlc 放在环境路径变量中才能像这样工作.控制面板 -> 系统 -> 高级 -> 环境变量,编辑路径系统变量,将路径添加到您的 mxmlc(需要重新启动)):

Here's the batch file I created to speed up the process (you have to have put mxmlc in your Environment Path variable for it to work like this. Control Panel -> System -> Advanced -> Environment Variables, Edit the Path System Variable, adding the path to your mxmlc (requires a reboot)):

cd C:\Projects\MyProject\Develop\Modules
mxmlc -link-report=MyAppReport.xml C:\Projects\MyProject\Develop\Source\Main.mxml
mxmlc -load-externs=MyAppReport.xml MyModule.mxml
move /Y MyModule.swf ..\Runtime\Modules

更多信息在这里:http://livedocs.adobe.com/flex/3/html/help.html?content=modular_4.html

希望有帮助!

这篇关于使用多个模块时优化 Flex的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆