actionscript-3apache-flexflex4.5mxml

Flex conditional statement: set VGroup height according to Label Text


In my Flex code I have a Label and a VGroup container. I want to set the height of the VGroup according to the Label text.

Here is the simplified code -

<s:Group height="100%" width="100%" >      
    <s:Group id="titleBar" width="100%" depth="50" >
        <s:Label id="titleDisplay" maxDisplayedLines="1" 
                     color="{ColorMap.WHITE}" 
                     color.bubble="{ColorMap.MAINTEXT}"
                     color.inactiveGroup="{ColorMap.MAINTEXT}"
                     left="10" right="35" top="1" bottom="0" minHeight="30"
                     verticalAlign="middle" textAlign="left" 
                     styleName="overlayTitle"/>
    </s:Group>

    <s:VGroup  width="100%" height="{(titleDisplay.text == "Create Pool")? "80%" : "100%"}" top="30">
        <s:Group id="contentArea" width="100%" height="100%">
        ....
        </s:Group>
    </s:VGroup>

</s:Group>

So I want to set the height to 80% if the Label's text is "Create Pool", otherwise 100%. But I am getting the following compilation error from the VGroup line -

Element type "s:VGroup" must be followed by either attribute specifications, ">" or "/>".

How to resolve this issue? I am following the code from the following link - How i write inline conditional statement in Flex with two expressions(case)?

Please guide me how to put the conditional statement in this case.

Thanks


Solution

  • I resolved this issue with a custom function init().

    <s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009" 
                 xmlns:s="library://ns.adobe.com/flex/spark"
                 creationComplete="init()">
    
    private function init():void
    { 
        if (titleDisplay.text == "Create Pool")
            {
                contentVGroup.height = contentVGroup.height * .8;
            }
    }
    

    This is perfectly working.

    Thanks