4

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/

1
  • Did you export a release build or are you comparing the debug build? Commented Jan 26, 2011 at 18:30

3 Answers 3

3

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.

1
  • We compile with debug=false, I updated the question to mention this.
    – Cyno
    Commented Jan 27, 2011 at 13:13
2

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?

1
  • We do have a lot of custom components that inherits from the main Flex components (Canvas, Box, Image, List, etc...). I'm not sure it has some benefit on the final generated code size. When you nest a Button or a CustomizedButton (inhereting Button) in a .mxml, does the final code size change ? That is why I was asking about deep analysis and best practice.
    – Cyno
    Commented Jan 27, 2011 at 13:26
1

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.

2
  • We do have a preloader in plain AS3 which handle basic tasks (environment tests, security, monitore main app loading). Unfortunately most of users are jumping directly to the main application where most of the code is used. As I mentioned in the question we already created modules for secondary features.
    – Cyno
    Commented Jan 27, 2011 at 13:19
  • I updated the question to add a link showing how people are accessing the app.
    – Cyno
    Commented Jan 27, 2011 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.