我有以下弹性组件:
<?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>
我试图通过将 currentState 设置为“male”来初始化组件的整个状态(包括选定的单选按钮)。这最初有效(选择了正确的单选按钮并且边框为蓝色):
但是当我单击另一个单选按钮时,用户界面有时会处于奇怪的状态 - 单选选择恢复为原始状态,但边框颜色会发生变化:
我错过了某种比赛吗?
我正在使用 flex 4.6.0 和 flash builder 4.7