PDA

View Full Version : Effect of Subclassing on swf size



arkum
December 8th, 2007, 03:11 PM
Howdy,

Can anyone explain the following...

I have a class that is huge: 'BaseClass'. For arguments sake lets say it is 5k.

In my Swf I use 10 classes that all subclass BaseClass, each is only 1k.

When I compile the swf, do each of these subclasses gain the weight of BaseClass, or do they share it?
ie. do all 10 subclasses become 6k each (making a total of 60k), or do they share the BaseClass (10 X 1k + 5k ) = 15k?

(I know my example is unrealistic, but hopefully you get my point).

Thanks

raal
December 8th, 2007, 03:28 PM
Short answer: Filesize: no, memory usage: yes.

Longer answer: On the disk your swf does not get any bigger. In memory, the actual footprint at any time depends on how many subclasses are running and maybe on what type BaseClass is. If you have instances running of all 10 subclasses at the same time then you get 10 times the BaseClass added to the memory footprint. Since each subclass can have different states set in the BaseClass, it pretty much has to be this way. However, there might be some cases where you do not get a real instance of your BaseClass, if it is static or large portions are constants. I don't know that for sure though, it requires more knowledge about the actionscript core OOP operations than I have at the moment.

raal