0
我有以下Flex組件:怪異的柔性行爲
<?xml version="1.0" encoding="utf-8"?>
<s:BorderContainer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="400"
height="300"
borderColor.male="blue"
borderColor.female="#FF00F6"
initialize="init(event)">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
protected function genderChanged(event:Event):void
{
setByRadioGroup();
}
protected function init(event:FlexEvent):void
{
currentState = "male";
//setByRadioGroup()
}
protected function setByRadioGroup():void {
currentState = genderGroup.selectedValue as String;
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<s:RadioButtonGroup id="genderGroup" change="genderChanged(event)">
</s:RadioButtonGroup>
</fx:Declarations>
<s:states>
<s:State name="male"/>
<s:State name="female"/>
</s:states>
<s:Form>
<s:FormItem label="name">
<s:TextInput name="nameField" id="nameField"/>
</s:FormItem>
<s:FormItem label="gender">
<s:RadioButton label="male" groupName="genderGroup" selected.male="true"/>
<s:RadioButton label="female" groupName="genderGroup" selected.female="true"/>
</s:FormItem>
</s:Form>
</s:BorderContainer>
IM試圖讓組件的整個狀態(含選定的單選按鈕),通過設置在currentState初始化爲「男」。這個作品最初(正確的單選按鈕被選中,邊框爲藍色):
但是當我點擊另一個單選按鈕的UI有時一個奇怪的狀態結束了 - 無線電選擇回覆到原來的,但邊界顏色變化:
是否有某種比賽在這裏我失蹤?
IM使用Flex 4.6.0和Flash Builder 4.7
您的單選按鈕似乎沒有'價值',所以我希望組的'selectedValue'在任何時候都爲null。 – RIAstar 2013-03-03 09:53:35
@RIAstar - 不,我跟蹤()編輯它並在那裏設置一個斷點,selectedValue正確地反映了所選單選按鈕的標籤 – radai 2013-03-03 09:55:23