RadioButton和RadioButtonGroup按钮的实现

来源:互联网 发布:软件测试分为哪些 编辑:程序博客网 时间:2024/05/15 13:52
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" label="Radio" fontSize="12">
    
<!-- 用RadioButton实现   -->
    
<mx:RadioButton x="61" y="36" label="2001" id="item1" groupName="flex"/>
    
<mx:RadioButton x="155" y="36" label="2002" id="item2" groupName="flex"/>
    
<mx:RadioButton x="229" y="36" label="2003" id="item3" groupName="flex"/>
    
<mx:RadioButton x="303" y="36" label="2004" id="item4" groupName="flex"/>
    
<mx:RadioButton x="395" y="36" label="2005" id="item5" groupName="flex"/>
    
<mx:Label x="10" y="10" text="flex是哪一年发布的" width="131"/>
    
<mx:Label x="10" y="111" width="131" id="answer_txt"/>
    
<mx:Button x="10" y="61" label="提交" id="sub" click="answer_txt.text=(item2.selected?'正确':'错误')"/>
    
    
<!-- 用RadioButtonGroup实现   -->
    
<mx:Label x="10" y="139" text="我最想干的事是什么" id="lbl1"/>
    
<mx:RadioButtonGroup id="my1"/>
    
<mx:RadioButton x="61" y="167" label="打架" groupName="my1" id="item21"/>
    
<mx:RadioButton x="143" y="167" label="学习" groupName="my1" id="item22"/>
    
<mx:RadioButton x="209" y="167" label="听歌" groupName="my1" id="item23"/>
    
<mx:RadioButton x="273" y="167" label="游戏" groupName="my1" id="item24"/>
    
<mx:RadioButton x="339" y="167" label="看书" groupName="my1" id="item25"/>
    
<!-- 每个RadioButton的groupName属性必须和RadioButtonGroup的id同名,否则两者就会无法联系起来  -->
    
<mx:Label x="10" y="223" id="wo"/>
    
<mx:Button x="10" y="193" label="提交" click="wo.text=(item22.selected?'正确':'错误')"/>
</mx:Application>
 
原创粉丝点击