RadioButtonGroup的使用

1、

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">
 
    <mx:Script>
        <![CDATA[
            import mx.events.ItemClickEvent;
 
            private function radioGroup_itemClick(evt:ItemClickEvent):void {
                var now:String = new Date().toTimeString();
                lbl.text = evt.label + " (" + now + ")";
            }
        ]]>
    </mx:Script>
 
    <mx:ApplicationControlBar dock="true">
        <mx:Label id="lbl" fontWeight="bold" />
    </mx:ApplicationControlBar>
 
    <mx:RadioButtonGroup id="radioGroup"
            itemClick="radioGroup_itemClick(event);" />
 
    <mx:VBox>
        <mx:RadioButton id="radioButton1"
                label="Red"
                group="{radioGroup}" />
        <mx:RadioButton id="radioButton2"
                label="Orange"
                group="{radioGroup}" />
        <mx:RadioButton id="radioButton3"
                label="Yellow"
                group="{radioGroup}" />
        <mx:RadioButton id="radioButton4"
                label="Green"
                group="{radioGroup}" />
        <mx:RadioButton id="radioButton5"
                label="Blue"
                group="{radioGroup}" />
    </mx:VBox>
 
</mx:Application>
2、

<?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" 
               viewSourceURL="srcview/index.html">

    <fx:Script>
        <![CDATA[
            protected function scoreClickHandler(event:MouseEvent):void
            {
                var score:Number = 0.0;
                
                if (group1.selectedValue=="True")
                    score=33.34;
                if (group2.selectedValue=="South Africa")
                    score=score+33.34;
                if (group3.selectedValue=="False")
                    score=score+33.34;
                scoreText.text = "You scored " + numberFormatter.format(score).toString()+"%";
            }
        ]]>
    </fx:Script>
    <fx:Declarations>
        <s:RadioButtonGroup id="group1"/>
        <s:RadioButtonGroup id="group2"/>
        <s:RadioButtonGroup id="group3"/>
        <mx:NumberFormatter id="numberFormatter"
                            precision="0"
                            rounding="nearest"/>
    </fx:Declarations>
    <fx:Style>
        @namespace "library://ns.adobe.com/flex/spark";
        
        RadioButton{ 
            baseColor: #FFFFFF; 
        }
        
    </fx:Style>
    
    <!-- Note: A custom panel skin is used for the Tour de Flex samples and is included in the
    source tabs for each sample.    -->
    <s:Panel title="RadioButton Sample" 
             width="100%" height="100%" 
             skinClass="skins.TDFPanelSkin">
        
        <s:HGroup horizontalCenter="0" top="10">
            <s:VGroup>
                <s:Label text="1) The sky is blue:"/>
                <s:RadioButton id="trueRadioBtn" label="True" groupName="group1"/>
                <s:RadioButton id="falseRadioBtn" label="False" groupName="group1"/>
            </s:VGroup>    
            <s:VGroup paddingLeft="20">
                <s:Label text="2) Which of the following is not a continent?"/>
                <s:RadioButton id="multiRadioBtnA" label="North America" groupName="group2"/>
                <s:RadioButton id="multiRadioBtnB" label="Europe" groupName="group2"/>
                <s:RadioButton id="multiRadioBtnC" label="Asia" groupName="group2"/>
                <s:RadioButton id="multiRadioBtnD" label="South Africa" groupName="group2"/>
            </s:VGroup>
            <s:VGroup paddingLeft="20">
                <s:Label text="3) Tallahasee is the capital of Alabama:"/>
                <s:RadioButton id="trueRadioBtn3" label="True" groupName="group3" />
                <s:RadioButton id="falseRadioBtn3" label="False" groupName="group3"/>
            </s:VGroup>
            <s:VGroup horizontalAlign="contentJustify">
                <s:Button id="scoreBtn" label="Score Me!" click="scoreClickHandler(event)"/>
                <s:Label id="scoreText"/>
            </s:VGroup>
        </s:HGroup>
        
        <s:Label bottom="20" left="5" width="100%" verticalAlign="justify" color="#323232" 
                      text="The RadioButton control is a single choice in a set of mutually 
exclusive choices. A RadioButton group is composed of two or more RadioButton controls with
the same group name. Only one member of the group can be selected at any given time." />
    </s:Panel>
    
        
</s:Application>



转载于:https://www.cnblogs.com/programmer-wind/archive/2012/03/05/2919645.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值