如何通过优化代码来减少SWF文件大小?

发布于 2024-10-14 13:39:26 字数 704 浏览 3 评论 0原文

考虑到我们已经完成了以下操作:

  • Flex Framework 作为 RSL
  • 使用 debug=false 进行编译
  • 在运行时加载大多数图像
  • 使用 flash 绘制功能绘制其他简单图像
  • 使用 pngquant 减少复杂图像
  • 为次要功能创建模块
  • 将范围应用于字体
  • 运行 FlexPMD 以查找死区代码和错误的复制粘贴
  • 运行 FlashOptimizer 和 secureSWF(结果很差)

今天我们的应用程序是 1358k:

  • 代码:978k - 72%
  • 图像:270k - 20%
  • 字体:110k - 8%

我们相信我们花了很多时间进行资产优化大部分工作都集中在代码上。 通过分析我们的链接报告,我们猜测代码的大部分来自 Flex .mxml 嵌套组件。我们认为我们的纯 AS 课程没有太多可做的。

是否有任何分析或编码最佳实践,以减少代码对 swf 文件大小的影响?

谢谢。

这是应用程序:http://www.pearltrees.com/nicolas/137698/

Considering we have already done the following actions:

  • Flex Framework as RSL
  • Compiling with debug=false
  • Loading most images at runtime
  • Drawing other simple images with flash draw features
  • Reducing complex images with pngquant
  • Creating modules for secondary features
  • Applying ranges to fonts
  • Running FlexPMD to find dead code and bad copy-paste
  • Running FlashOptimizer and secureSWF (with poor results)

Today our application is 1358k:

  • Code: 978k - 72%
  • Images: 270k - 20%
  • Fonts: 110k - 8%

We believe we spent a lot of time into asset optimization and most of the work is remaining on the code.
By analyzing our link-report, our guess is that the heavy part of the code is comming from Flex .mxml nested components. We don't think there is much to do on our pure AS classes.

Is there any analysis or coding best practice in order to reduce the impact of the code on the swf filesize ?

Thanks.

Here is the application : http://www.pearltrees.com/nicolas/137698/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

如果没有你 2024-10-21 13:39:26

在我的实践中,我通常没有大的最终 swf 文件,所以我只想提一件事。直接使用 mxmlc 我们不应该忘记添加(当然是最终构建)参数/属性

调试=“假”

以其他方式最终的 swf 将几乎增大 2 倍。

In my practice I usually don't have big final swf files, so I want to mention only one thing. Using mxmlc directly we should not forget to add (for the final build of course) parameter/attribute

debug = "false"

in other way final swf will be almost 2 times bigger.

白云不回头 2024-10-21 13:39:26

.mxml 中是否有一个彼此相似的对象,您可以将其转换为通用类并以编程方式自定义?

do you have an objects in the .mxml that are similar to each other that you could turn into a generic class and customize programatically?

煮茶煮酒煮时光 2024-10-21 13:39:26

考虑研究预加载器和模块。

在不了解您的应用程序的情况下,很难具体说明,但是 自定义预加载器< /a> 有时可以对感知下载时间有很大帮助。让我们面对现实吧,要求用户无所事事地盯着进度条是令人难过的,但你可以做得更好。

这里常见的示例是您需要应用程序用户登录,或在跳转到主应用程序之前选择一些基本详细信息。通过将第一个表单实现为预加载器,您的应用程序将在用户与该表单交互时在后台继续下载。

缺点:您的预加载器代码无法访问 Flex 的所有优点。您必须在普通的旧 AS3 中绘制 UI 并实现交互。不过,在某些情况下,额外的工作是值得的。

弹性模块是另一个值得研究的东西。在复杂的 Flex 应用程序中,并非所有内容都是常用的。如果您从主应用程序中删除较少使用的部分并将它们移动到 您按需加载的模块,您也许可以从初始下载大小中节省相当多的字节。

Consider looking into preloaders and modules.

Without knowing your application, it's hard to be specific, but a custom preloader can sometimes help a lot with perceived download time. Let's face it, asking the user to idly stare at a progress bar is sad, and you can do better.

The usual example here is that your need your application users to login, or select some basic details before jumping into the main application. By implementation that first form as a preloader, your application will keep downloading in the background while your user interacts with that form.

The downside: Your preloader code doesn't have access to all the Flex goodness. You'll have to draw your UI and implement your interaction in plain old AS3. Still, the extra work can be worth it in some situations.

Flex Modules are the other thing that'd be worth looking into. In a complex Flex app, not everything is commonly used. If you cut the lesser-used bits from the main application and move them into a module you load on-demand, you may be able to save a fair amount of bytes from the initial download size.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文