Flex中获取RadioButtonGroup中的RadioButton的值
1、设计源码
<?xml version="1.0" encoding="utf-8"?>
<s:Application 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="100%" height="100%">
<s:layout>
<s:BasicLayout/>
</s:layout>
<fx:Declarations>
<s:RadioButtonGroup id="radiogroup"/>
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.controls.Alert;
/*获取Radio中的值函数*/
protected function clickHandler(event:MouseEvent):void
{
//获取radioButton的label值
var radio:String = radiogroup.selectedValue.toString();
//打印radioButton的label值
Alert.show("选择:"+radio);
}
]]>
</fx:Script>
<mx:VBox width="100%" horizontalAlign="center">
<mx:HBox width="100%" horizontalAlign="center" paddingTop="100">
<s:RadioButton label="篮球" groupName="radiogroup" selected="true"/>
<s:RadioButton label="足球" groupName="radiogroup"/>
<s:RadioButton label="排球" groupName="radiogroup"/>
</mx:HBox>
<s:Label height="10"/>
<s:Button label="获取Radio值" click="clickHandler(event)" cornerRadius="8"/>
</mx:VBox>
</s:Application>
2、设计结果
(1)初始化时
(2)选择“足球”时
(3)选择“排球”时