CounterMarch Systems

use your brain


We used to blog more before twitter came along.

Optimizing with Flex 3

We've been doing a lot of Flex work lately. but didn't compile any of our production apps under Flex 3 until yesterday - we shouldn't have waited!

One application we've been working on contains 9 modules and one "main" application. Under Flex 2. each of these modules was compiled as its own application - building in the Flex framework and Cairngorm code on every compile. This jacked up the swf sizes considerably. but since we were largely under 500k. it was tolerable. Not great by any measure. but it would do.

Yesterday. I opened up the project in Flex Builder 3 and adjusted the Flex project settings to optimize these Flex modules against the main application file. I was just poking around the project settings and figured that if it was "optimizing" it would either a) work out well or b) crash spectacularly. It was amazingly easy to set this up...and then I ran the build. The file size differences were amazing! I was seeing swf sizes that were anywhere from 10-35% of the original size - a MASSIVE improvement! The best part is the application still runs - no coding changes. just a configuration tweak and now our app is a fraction of its former size. Be careful. though...optimizing will prohibit the compiled module from being loadable by any other Flex app. This is not usually a problem (in our case it isn't).

The next natural step was to mess with the Runtime Shared Library feature. In this application. we can encapsulate the Flex Framework in a shared library that will only ever need to be downloaded ONCE by the client. The savings here weren't quite as great. but I think there's more optimization I can do to that as well.

Here are the stats (all numbers in KB):

Module Flex 2 Flex 3 Flex 3 w/RSL
A 343 34 46
B 579 98 110
C 471 56 70
D 634 156 98
Main 810 581 466
E 466 87 66
F 307 26 38
G 436 26 83
H 337 33 45
I 743 224 187
Subtotal 5126 1321 1209
Framework RSL N/A N/A 526
Total 5126 1321 1735

We've still got a good bit of work to do on this app. but the initial sweep suggests we're going to be able to really cut down on the data traffic from our initial build. Can't complain about that!

Comments
Sci-Fi Si's Gravatar Thanks for the 'heads up'

It's certainly an improvement, but the 'Main' file is still 581k,
even with RSL it's still 466k and even that I find completely
unacceptable. I do like the look of Flex 3, but I really
don't want my visitors to have to download that much code
before they see any results on screen. I can fit the graphics,
code, sound effects, 3D animations, input boxes for most of
my site in less memory than it takes just to load the Flex
libraries...

If I can't find a way to use Flex with a reasonable filesize
ie. 100k then I'll just stick with Flash.

Any ideas?

Many thanks
# Posted By Sci-Fi Si | 1/8/09 8:41 PM

About the blog

7 years of outstanding software development

CounterMarch Systems is a professional consulting firm specializing in Adobe technologies with a special focus on higher education.

2771 Red Oak Circle
Bethlehem, Pennsylvania 18017
610.280.3455
Contact Us