问题描述
我有几个单选按钮我拖放同一组中。在main.as我添加点击事件监听器。
I have a few radiobuttons I drag and drop within same group. In main.as I added click event listener.
如何获得所选择的单选按钮?处理目标参数不包含任何引用。
How do I get the selected radiobutton ? handler target argument doesn't contain any reference to it.
推荐答案
抢参考目前的RadioButtonGroup,并访问选择的参考,这将返回一个引用到组中选定当前单选按钮。
Grab a reference to the current RadioButtonGroup and access the selection reference, this will return a reference to the current radio button that is selected in the group.
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fl/controls/RadioButtonGroup.html
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fl/controls/RadioButton.html#group
var rbg:RadioButtonGroup = RadioButton(e.currentTarget).group;
var selectedRadioButton:RadioButton = rbg.selection;
//Get the group name
trace(selectedRadioButton.groupName);
或者你可以有你的单选按钮的复合if语句,像这样:
Alternatively you can just have your radio buttons in a compounded if statement like so:
if(radioButton1.selected == true){
}else if (radioButton2.selected == true){
}
这篇关于闪存单选按钮:我如何才能所选的单选按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!