开发者

How to reduce SWF filesize by optimizing the code?

开发者 https://www.devze.com 2023-02-06 17:33 出处:网络
Considering we have already done the following actions: Flex Framework as RSL Compiling with debug=false

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开发者_Python百科 : http://www.pearltrees.com/nicolas/137698/


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.


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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消