includeInLayout hide/show a component

20 sec read

Let’s say you have a Label and you want to show this label only when condition == true, you may do this:

<mx:VBox>
    ... other components ...
    <mx:Label text="this is label" visible="{condition}"/>
    ... other components ...
</mx:VBox>

But you will find your invisible Label still takes its space. Then you may try something like

<mx:VBox>
    ... other components ...
    <mx:Label text="this is label" visible="{condition}" height="{condition?20:0}" />
    ... other components ...
</mx:VBox>

Then you need to know the exact height of Label (20 is a good guess but not exact).

The ultimate solution is to use includeInLayout and visible (Yes, you need specify both visible and includeInLayout)

<mx:VBox>
    ... other components ...
    <mx:Label text="this is label" visible="{condition}" inclueInLayout="{condition}" />
    ... other components ...
</mx:VBox>

related links: an example



写作助手,把中式英语变成专业英文


Want to receive new post notification? 有新文章通知我

How much money did I make from an app?

Undoubtedly some people are very successful in making money by developing a smartphone app. Back in 2012 I developed an app called “Handbook of Brain” which is a collected resources of brain anatomy, function and diseases. I put the app i
Xu Cui
27 sec read

Handy programs to visualize NIRS data (2): plotTopoMap

Often you need to view the spatial pattern of activation as in the example below. plotTopoMap allows you to do that. It probably only works for Hitachi devices where the spatial relationship between channels are known. In the above example, the activ
Xu Cui
37 sec read

Flash 3D video demo

Racer Ostrova Zombie
Xu Cui
0 sec read

Leave a Reply

Your email address will not be published. Required fields are marked *