[英]Flex conditional statement: set VGroup height according to Label Text
在我的 Flex 代碼中,我有一個 Label 和一個 VGroup 容器。 我想根據Label文本設置VGroup的高度。
這是簡化的代碼 -
<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>
所以如果標簽的文本是“創建池”,我想將高度設置為 80%,否則為 100%。 但是我從 VGroup 行收到以下編譯錯誤 -
Element type "s:VGroup" must be followed by either attribute specifications, ">" or "/>".
如何解決這個問題? 我正在關注以下鏈接中的代碼 - 如何使用兩個表達式(案例)在 Flex 中編寫內聯條件語句?
請指導我如何在這種情況下放置條件語句。
謝謝
我使用自定義 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;
}
}
這是完美的工作。
謝謝
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.