View comments | RSS feed
Properties | Events | Examples Frames | No Frames

mx.controls
Class RadioButtonGroup




class RadioButtonGroup

The RadioButtonGroup control defines a group of RadioButton controls which act as a single mutally exclusive control. That is, only one RadioButton control can be selected at a time. The id property is required when you use the <mx:RadioButtonGroup> tag to define the name of the group.

MXML Syntax

The <mx:RadioButtonGroup> tag inherits all the properties of its parent classes, and the following properties:

 <mx:RadioButtonGroup
id="Required - No default."
enabled="true|false"
groupName="No default.
labelPlacement="right|left|bottom|top"
selectedData=" If the RadioButton does not define the data property,
Flex sets selectedData to the value of the label property.
"
click="Event handler; no default."
change="Event handler; no default."
/>

Click here to view the Examples

See Also
    RadioButton



Properties
       enabled: Boolean
If true, selection is allowed.
       groupName: String
Name of the group of RadioButton controls.
       labelPlacement: String
Orientation of the label relative to the RadioButton icon for all controls in the group.
       selectedData: Object
Value of the data property of the selected RadioButton control in the group.
       selection: mx.controls.RadioButton
Contains a copy of the currently selected RadioButton control in the group.
staticversion: String
Version string for this class.



Events
changeBroadcast when the value of the control changes due to user interaction. The target property of the event object contains a reference to the component that triggered the event. The type property contains the name of the event, change.
clickBroadcast when a user selects a RadioButton control in the group. You can also set a handler for individual RadioButton controls. The target property of the event object contains a reference to the component that triggered the event. The type property contains the name of the event, click.



Property Detail

enabled

enabled: Boolean  

If true, selection is allowed.


groupName

groupName: String  

Name of the group of RadioButton controls. This property is for backward compatibility with Macromedia Flash only. Use the id property of the <mx:RadioButtonGroup> tag to define the name of the group.


labelPlacement

labelPlacement: String  

Orientation of the label relative to the RadioButton icon for all controls in the group. You can override this setting for the individual controls. Possible values are right, left, bottom, and top. The default value is right.


selectedData

selectedData: Object  

Value of the data property of the selected RadioButton control in the group. If the RadioButton control does not define the data property, Flex sets selectedData to the value of the label property.


selection

selection: mx.controls.RadioButton  

Contains a copy of the currently selected RadioButton control in the group.


version

static  version: String  

Version string for this class.


Examples
RadioButtonGroupExample.mxml
<?xml version="1.0" encoding="utf-8"?>
<!-- Simple example to demonstrate RadioButtonGroup control -->
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" width="100%" height="100%"
    backgroundColor="#FFFFFF">

    <mx:Script>
        <![CDATA[
           
           import mx.controls.Alert;

           function initCredit()
           {
            	 radioVisa.data= mx.validators.CreditCardValidator.kVisa;
            	 radioMC.data= mx.validators.CreditCardValidator.kMasterCard;
           }
	   
	   function check()
	   {
	    	 if(mx.validators.Validator.isValid(this,'myModel'))
	     	 {
		    Alert.show(" This is valid card number ", "Success!!!", Alert.OK);
             	 }

	   }
       ]]>
    </mx:Script>

    <mx:CreditCardValidator field="myModel"/>

    <mx:Model id="myModel">
        <cardType>{cardTypeRadio.selectedData}</cardType>
        <cardNumber>{cardNumber.text}</cardNumber>
    </mx:Model>

    <mx:Panel title="Radio Button Group Panel" height="40%" width="55%">

        <mx:Form borderStyle="none" width="100%" height="100%">

            <mx:FormItem label="Select credit card type: " initialize="initCredit();">
                <mx:RadioButtonGroup id="cardTypeRadio"/>
                <mx:RadioButton id="radioVisa" label="Visa" groupName="cardTypeRadio" />
                <mx:RadioButton id="radioMC" label="MasterCard" groupName="cardTypeRadio"/>
                <mx:TextInput id="cardNumber"/>
                <mx:Button label="Check validity" click="check()" />
            </mx:FormItem>

        </mx:Form>

    </mx:Panel>

</mx:Application>




Comments


Robin Hilliard said on Mar 27, 2006 at 7:46 PM :
I think this example shouldn't involve the validator - just some more basic radio / radio group stuff

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flex/15/asdocs_en/mx/controls/RadioButtonGroup.html