Flex中获取RadioButtonGroup中的RadioButton的值

来源:互联网 发布:2017淘宝发布宝贝教程 编辑:程序博客网 时间:2024/06/10 12:22

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)选择“排球”时


1 0
原创粉丝点击