PDA

View Full Version : Loading HBOX at runtime (Flex and ac3).


zanshin
09-16-2009, 04:39 PM
Lets say I have several HBOX components that hold a Label / Spacer / and 2 TextInput fields. However I don't know whether I will need to display 1 or all the HBOX components. If I use visible=false, I get unwanted spaces between some of the HBOX's. How can I have a component not display and not take up space on my screen.

sample code below (three HBox's as described above):
<mx:HBox width="100%">
<ddd:SmartDeskTextArea height="24"
text="Elective Deferrals:" />
<mx:Spacer width="140" height="1"/>
<ddd:SmartDeskNumberInput width="100"/>
<mx:Spacer width="85" height="1"/>
<ddd:SmartDeskNumberInput width="100" />
</mx:HBox>

<mx:HBox width="100%">
<ddd:SmartDeskTextArea height="24"
text="Contributions:" />
<mx:Spacer width="140" height="1"/>
<ddd:SmartDeskNumberInput width="100"/>
<mx:Spacer width="85" height="1"/>
<ddd:SmartDeskNumberInput width="100" />
</mx:HBox>

<mx:HBox width="100%">
<ddd:SmartDeskTextArea height="24"
text="Dividends:" />
<mx:Spacer width="140" height="1"/>
<ddd:SmartDeskNumberInput width="100"/>
<mx:Spacer width="85" height="1"/>
<ddd:SmartDeskNumberInput width="100" />
</mx:HBox>

sydd_hu
09-17-2009, 02:42 AM
every UIcomponent has a property called includeInLayout.
If you set it to false it wont take up space.
So if you dont want it to show up at all:
<mx:HBox width="100%" visible="false" includeInLayout="false">

Peter Cowling
09-17-2009, 03:27 PM
And you can use states include/exclude in Flex 4, which is the same idea, but without visibility, and a little nicer to work with.

zanshin
09-20-2009, 08:59 PM
awesome.. that worked great.