How to reduce SWF file size by optimizing code?

Given that we have already completed the following steps:

  • Flex Framework as RSL
  • Compiling with debug = false
  • Download most images at runtime
  • Draw other simple images with flash drawing features
  • Reducing complex images with pngquant
  • Creating modules for advanced features
  • Applying ranges to fonts
  • Running FlexPMD to find dead code and tight 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 that we spent a lot of time optimizing the assets, and most of the work remains in the code. By analyzing our link report, we assume that the bulk of the code comes from the Flex.mxml nested components. We don’t think much needs to be done in our pure AS classes.

Is there any analysis or coding of best practices to reduce the impact of code on swf files?

Thanks.

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

+4
source share
3 answers

In my practice, I usually don't have large final SWF files, so I want to mention only one. Using mxmlc , we must not forget to add (for final assembly) parameter / attribute

debug = "false"

otherwise, the final swf will be almost 2 times larger.

+3
source

Do you have objects in .mxml that are similar to each other that you can turn into a common class and configure it programmatically?

+2
source

Look at preloaders and modules.

Without knowing your application, it is difficult to be specific, but a custom preloader can sometimes help a lot with perceived load times. Let's face it, asking the user to calmly look at the progress indicator, it's sad, and you can do better.

A common example here is that you need your application users to log in or select some basic information before moving to the main application. With an implementation that first forms as a preloader, your application will continue to download in the background while your user interacts with this form.

Disadvantage: Your preload code does not have access to all Flex features. You will need to draw your interface and implement your interaction in a simple old AS3. However, the extra work may be worth it in some situations.

Flex modules are another thing to watch out for. In a complex Flex application, not everything is commonly used. If you cut out less-used bits from the main application and move them to the module that you load on demand , you can save a fair number of bytes from the initial load size.

+1
source

Source: https://habr.com/ru/post/1337184/


All Articles