为什么一个简单的 Flex 应用程序需要 2.4 MB 的数据?
我有一个 Flex 应用程序此处
如果您打开该链接,您会看到它下载需要相当长的时间(第一个栏完成后,屏幕会空白一段时间,然后显示应用程序),尽管它只是一个只有一个屏幕(尽管有 2 个状态)的简单 Flex 应用程序。
我在打开 firebug 的情况下打开了这个应用程序,我注意到它花费这么长时间的原因是浏览器正在下载 2.4 MB (!) 的数据只是为了显示那个应用程序。 实际应用程序 .swf 文件只有 88 KB,但还下载了更多内容。
一些正在下载的额外 .swf 文件(相当大)包括:
mx.swf、spark.swf、spark Skins.swf、text-layout.swf 和其他...每个的大小约为300-400 KB!
我过去在 Flex 3 中开发了一些东西,但根本不是那样的。
我在这里缺少什么?
谢谢。
PS:我正在使用 Flash Builder 4.5 for PHP。
I have a Flex application here
If you open that link, you'll see it takes quite a long time to download (after the first bar is complete, the screen gets blank for a while and then the app is shown), even though it's only a simple Flex app with only one screen (albeit 2 states).
I opened this app with firebug turned on and I noticed that the reason why it's taking so long is because the browser is downloading 2.4 MB (!) worth of data just to show that app. The actual app .swf file is just 88 KB but a lot more is being downloaded as well.
Some extra .swf files (quite large) that are being downloaded as well are:
mx.swf,spark.swf, spark skins.swf,text-layout.swf and others... Each of those is about 300-400 KB in size!
I developed some things in Flex 3 in the past and it wasn't like that at all.
What am I missing here?
Thank you .
P.S.: I am using Flash Builder 4.5 for PHP.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你是对的,它似乎需要很长时间才能加载。我不知道为什么没有正式的代码审查。
我没有明确的答案给你。但是,这里有一些需要注意的事项:
1) 在每个 SDK 版本中,Adobe 都将 Flex 框架拆分为多个;更多封装的 SWF 文件。实际的 Flex Framework 文件可以作为 SWZ 文件分发。这些是 Adobe 编译的库,可以跨多个域缓存。理论上,这些文件不必在每次应用程序加载时下载;导致文件大小更小。不过,我相信您必须将框架设置为作为 RSL 加载才能从中受益。 Flash Builder 项目属性中应该有此设置。
2)看来您上传了 bin-debug 文件夹。确保在投入生产之前导出发布版本。这将生成一个小的 SWF 文件供您分发,这可能会有所帮助。
3) 我希望 Flex 编译器能够优化生成的 SWF,使其不包含不需要的类。我不确定这与为您的应用程序下载的额外 SWF 有什么关系。您使用任何 MX 组件吗?您是否使用任何使用文本布局框架的组件? (一些 Flex 文本控件在幕后使用它)。如果不;理想情况下,如果您不使用这些额外文件(mx.swf 和 text-layout.swf),则不会下载这些文件。因此,您也许能够检查代码并使用等效项来优化它们。
4) 你的应用程序启动时会做什么?您确定这里的问题是所有这些文件都正在加载吗?或者代码中是否有某些内容阻止了应用程序的快速设置?
You're right it does appear to take a long time to load. I'm not sure why without a formal code review.
I don't have an explicit answer for you. But, here are a few things to note:
1) With each SDK release, Adobe has been splitting the Flex Framework up into multiple; more encapsulated SWF files. The actual Flex Framework files can be distributed as SWZ files. These are Adobe compiled libraries that can be cached across multiple domains. In theory these files do not have to be downloaded each time the app loads; leading to even smaller file size. I believe you have to set the framework to load as an RSL to benefit from this, though. There should be settings for this within Flash Builder project properties.
2) It seems like you uploaded the bin-debug folder. Be sure to export a release build before moving into production. This will result in a small SWF file for you to distribute, which may help.
3) I expect the Flex Compiler to optimize the resulting SWF as to not include classes it does not need. I'm not sure how this relates to the extra SWFs being downloaded for your app. Are you using any MX Components? Are you using any components that use the text layout framework? (Some Flex text controls use it under the hood). If not; ideally those extra files (mx.swf and text-layout.swf) would not be downloaded if you're not using those files. So, you may be able to review code and optimize those out by using equivalents.
4) What does your app do on startup? Are you sure the issue here is that all these files are being loaded? Or is there something in the code that prevents a quick setup of your application?
您列出的其他 SWF 包含应用程序所需的库。它们称为运行时共享库 (RSL)(请参阅链接了解详细信息)。
RSL 的好处是它们可以被浏览器和 Flash Player 缓存,因此首次加载的大小为 2.4 Mb。更重要的是,RSL 的特殊形式(称为 SWZ)是签名库,可以由 Flash Player 直接在所有 Flash 应用程序中进行缓存。要优化 RSL,请参阅以下链接。
另一种方法是通过 Flash Builder 中的项目设置在应用程序中包含所需的类。整体大小会更小,并且它将是单个 SWF,但它会在您编译和部署新应用程序版本时一直加载。
The additional SWFs you listed contain libraries which are necessary for the application. They are called Runtime Shared Libraries (RSLs) (see the link for details).
The benefit of RSLs is they can be cached by browser and Flash Player and so 2.4 Mb are the size for the first time loading. Even more, the special form of RSLs, called SWZ, are signed libraries which can be cached by Flash Player directly across all the Flash applications. To optimize your RSLs see the following link.
Another way is to include required classes in your application via Project Settings in Flash Builder. The whole size will be less and it will be single SWF but it will be loaded all the time you compile and deploy new application version.