views:

112

answers:

3

Compile the following module with all framework SWC-s excluded in release mode in Flex 4:

<mx:Module xmlns:fx="http://ns.adobe.com/mxml/2009" 
 xmlns:s="library://ns.adobe.com/flex/spark" 
 xmlns:mx="library://ns.adobe.com/flex/mx"/>

The SWF size will be 35,658 bytes.

Now generate link report via -link-report for this SWF and load it via -load-externs. Size of the SWF now is 33.174 bytes.

If you check link report now, you will see that some framework classes like mx.modules:IModuleInfo or mx.utils:LoaderUtil are still there.

How to exclude them from SWF?

A: 

You are excluding framework SWCs by using RSLs, right?

If I had to guess, those classes are required by Modules and there is a reason for compiling them into the class. I'm sure Adobe was meticulous when creating RSLs and put a lot of thought into what should or should not be included in the main SWF.

I wonder why this is important, though. A 30K swf is really small.

www.Flextras.com
30K is small, but not for an empty SWF. If you want to have simple plugins for your app, then you wind up with lets say 40K per plugin out of which you use 25%. Imagine you have 10-20 plugins and it starts to make a real difference.
back2dos
Every once in a while I see people talk about the size of "Hello World" style apps as an indicator of something about the platform (bloat, ineffeciency, etc.. ). However, size for Flex Apps does not increase in relation to functionality. Adding another tag does not mean you'll double the size of your app. I'd recommend putting this off and dealing with it when (or if) it becomes a problem. I suspect a bigger issue will be memory management of loading /unloading plugins; not the size of plugins.
www.Flextras.com
We have 15 modules, 7 of which are loaded at startup. We load 210 kb extra. It is a problem ;(
Maxim Kachurovskiy
What is the problem? Load time? Setup time? Most Flex Apps I've worked with are in the 500K range. I wouldn't even start to worry until the swf is over 1MB.
www.Flextras.com
I'm Maxim's collegue. Our app is around 2.5Mb + 300-500Kb of a skin SWF. It just does a lot. So making it slimmer is an effort worthy task.
Hrundik
My intuition is that you're barking up the wrong tree trying to force swfs to not include classes; that I suspect were put in there for a reason. There may be other ways to optimize the SWF though; but without reviewing the code; I'm not sure where to point you.
www.Flextras.com
A: 

Hi,

The problem is that the standard components are not in the client runtime enviroment.

For example, in Flash with AS2 or AS3 if you use a ComboBox you have more than 20KB of overhead because the binaries for the component must be packed with your swf. This happend with Flex too. To make an small binary I used an small footprint library with the flash components, but this was for Flash AS2.

Good Luck.

Jonathan Barbero
I'm going to load that SWF into `ApplicationDomain` that contains all Flex SDK classes, so that's not a problem. It looks more like a compiler bug.
Maxim Kachurovskiy
A: 

I guess you have to dig through the link report. Find out which classes depend on mx.modules:IModuleInfo and mx.utils:LoaderUtil, and you're likely to understand how or why this happens.

It must be quite many classes, because the once mentioned including their dependencies have 6 KB raw and 2.8 KB optimized size.

greetz
back2dos

back2dos