废话不说下面是代码
<s:Label x="10" y="10" text="我是那年出生的?? "/>
<s:RadioButton id="rb1" x="25" y="48" label="90"/>
<s:RadioButton id="rb3" x="107" y="43" height="23" label="92"/>
<s:RadioButton id="rb2" x="66" y="48" label="91"/>
<s:Button x="25" y="74" label="确定" click="button2_clickHandler(event)"/>
<s:VGroup x="272" y="27" click="ice()">
<s:RadioButton id="rbg1" label="按钮 1" groupName="radiogroup2"/>
<s:RadioButton id="rbg2" label="按钮 2" groupName="radiogroup2"/>
</s:VGroup>
<fx:Script>
<![CDATA[
import mx.controls.*;
import mx.controls.Alert;
import mx.events.*;
var mym:Menu;
protected function button2_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
Alert.show(rb1.selected?'正确':'错误'); 一个小判断语句 相信大家都知道
}
function ice():void
{
if (rbg1.selected)
{
Alert.show("按钮1");
}
else
{
Alert.show("按钮2");
}
}
]]>
</fx:Script>
这篇博客介绍了在Flex中如何使用RadioButton和RadioButtonGroup组件。通过示例代码展示了如何创建单选按钮并实现点击事件,以及在VGroup中使用groupName属性进行分组操作。同时,提供了一个简单的事件处理函数来验证用户的选择。
4096

被折叠的 条评论
为什么被折叠?



