2/9/2011 11:23:44 PM
Title:
Difference between addChild and includeInLayout
Hi all..
I need to knw the difference between addChild(button) and includeInLayout=true.
scenario:
1)I have a button1 in mxml with include in layout as false.
in my creation complete method of the file, i do the following operation..
a) button1.includeInLayout=true;
b)this.addChild(button1);
What is the difference between a and b. though both works, which one is efficient?
2/10/2011 3:08:59 AM
button1.includeInLayout=true; --> Its default value so you don't need to set it to true. It wont effect anything.
when you addChild an object in flash its added to flash object hierarchy. When a object is added its by default included in layout and flex has to make calculations to place it considering all other components.
If we set an object "includeInLayout = false" flex will ignore its size and can place this component below or above the other components. It wont be adjusted to fit with other components.
2/10/2011 3:28:48 AM
when components are placed in a container like vBox they are placed adjacent to each other by measuring there dimensions by Flash Builder. If we set includeInLayout= false then that component is ignored and other components are allocated its space. It may overlap others or will be overlapped by others.
Usually this property is set to false for hidden components. Which are required to made visible later. So they are includInLayout later when there visibility is set to true. This is done sometimes to speedup the application initialize time and improve performance.