views:

11

answers:

1

Hi ,

I guess this is a basic question but I could not find the solution.

I want to display checkbox or button at the same position based on user role. How can I do this. I cannot give x and y position same for both radio button and button as I will not know the location in my application. Is there any other way by which I can display only one component based on boolean value.

Sample code:

<mx:HBox x="272" y="93" width="300" borderThickness="2" borderColor="0x000000" borderStyle="solid">
    <mx:CheckBox label="CheckBox"  visible="{role}"/>
    <mx:Button label="Button" visible="{!role}"/>
</mx:HBox>

<mx:Script>
    <![CDATA[

        var role:Boolean=true;

    ]]>
</mx:Script>
+1  A: 

The includeInLayout property is what you want:

<mx:CheckBox label="CheckBox"  visible="{role}" includeInLayout="{role}"/>
<mx:Button label="Button" visible="{!role}" includeInLayout={!role}/>

If this property is set to false, then the control in question won't "take up space" in your HBox.

Matt Dillard
Thank you that works prefect.
firemonkey