I have created some components and also add some components
in my application at run time (based on the conditions) using
action script. Everything works fine. But the main application file
size is increasing when i add more components. For example i had 3
components, if i add two components based on the conditions the
main application file size is 630kb. If i remove the any one of the
components the main application size is reduced. But I need to use
3 components which is based on the conditions with less file size.
is it possible?
I think you will find that in the second case the compiler
does not link in any of the code relating to your component3, as it
is aware that you never in fact use it. In the first case the code
is present in the SWF file, even if at run-time you choose a code
path that means it is never instantiated.
As a quick test, in the second case if you replace the
private var comp3:component3=new component3();
(in other words declare and instantiate at the same time)
then I suspect you will find the size goes back up again.
Personally I prefer the style you had originally, where the
instantiation is kept in a separate place, but this would help
identify where the size was coming from.