In the current tutorial you will come to know about the RadioButtonGroup control of Flex. The RadioButtonGroup control in Flex is a set of choices which are mutually exclusive, in RadioButton we need to specify the group name in each of the RadioButton, but in this control we declare the name of the group only once in the RadioButtonGroup tag. The examples will help you to learn RadioButtonGroup more effectively.
In the current tutorial you will come to know about the RadioButtonGroup control of Flex. The RadioButtonGroup control in Flex is a set of choices which are mutually exclusive, in RadioButton we need to specify the group name in each of the RadioButton, but in this control we declare the name of the group only once in the RadioButtonGroup tag. The examples will help you to learn RadioButtonGroup more effectively.RadioButtonGroup in Flex:
The RadioButtonGroup control in Flex is a set of choices which are mutually exclusive, in RadioButton we need to specify the group name in each of the RadioButton, but in this control we declare the name of the group only once in the RadioButtonGroup tag. We can select any one RadioButton at a time. This control has number of RadioButtons which are clubbed as a single group. Only one member of this group can be selected at a time. We can not select more than one radio button at a time.
<mx:RadioButtonGroup> tag is used to access this control, we can put an id to this control if we need to access from any other tag in MXML file or in ActionScript file. As in the following example we use this tag. itemClickHandler is used to identify which button has been selected.
Example:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.ItemClickEvent;
public function listDisp(event:ItemClickEvent):void{
if(event.index==0)
{
Alert.show("JavaFx");
}
else if(event.index==1){
Alert.show("GWT");
}
else{
Alert.show("Flex");
}
}
]]>
</mx:Script>
<mx:Panel title="RadioButtonGroup Example " horizontalCenter="10" verticalCenter="10" paddingBottom="10" paddingLeft="10" paddingRight="10" paddingTop="10">
<mx:RadioButtonGroup id="ria" itemClick="listDisp(event);" />
<mx:RadioButton label="Sun" groupName="ria" id="sun" value="sn"/>
<mx:RadioButton label="Google" groupName="ria" id="google" value="ggl"/>
<mx:RadioButton label="Adobe" groupName="ria" id="ms" value="mic"/>
</mx:Panel>
</mx:Application>
Output: