flex动态单选按钮,如何获取选定单选按钮的值
我正在创建像这样的动态单选按钮,
for(var i:Number=0;i<xml.loc.length();i++)
{
var radioBtn:RadioButton=new RadioButton();
radioBtn.x=150;
radioBtn.y=150;
radioBtn.label=xml.loc[i];
countryChoice.addChild(radioBtn);
radioBtn.addEventListener(MouseEvent.CLICK,radiobuttonclickhandler)
function radiobuttonclickhandler(event:MouseEvent):void
{
//here i need to get the selected radio button value.
lblname.text=radioBtn.label
}
}
我需要获取我选择的标签名称的值。该怎么做?
I am creating dynamic radion button like this
for(var i:Number=0;i<xml.loc.length();i++)
{
var radioBtn:RadioButton=new RadioButton();
radioBtn.x=150;
radioBtn.y=150;
radioBtn.label=xml.loc[i];
countryChoice.addChild(radioBtn);
radioBtn.addEventListener(MouseEvent.CLICK,radiobuttonclickhandler)
function radiobuttonclickhandler(event:MouseEvent):void
{
//here i need to get the selected radio button value.
lblname.text=radioBtn.label
}
}
i need to get the value of labelname in which one is i am selected.how to do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不要使用
groupName
,而是使用group
来一起设置radioButton。group
是一个包含 RadioButtonGroup 对象的属性。这个对象可以知道哪个RadioButton 通过使用
selection
属性进行选择。Dont'use
groupName
, butgroup
to set radioButton together.group
is a property which contains a RadioButtonGroup object. This object can know whichRadioButton is selected by using
selection
property.在您的循环中将单选按钮添加到单选按钮组。
在“for”循环之后,您将得到如下内容:
(设置与ragiobuttongroup id相同的groupName!)
现在您可以这样做:
In your cycle add radio button to a radiobutton group.
After your "for" cycle you will have something like this:
(set the same groupName as ragiobuttongroup id!)
Now you can do that: