RadioButton
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. Selecting an unselected group member deselects the currently selected RadioButton control in the group.
RadioButton user interaction
If a Radiobutton control is enabled, when the user moves the mouse pointer over an unselected RadioButton control, the button displays its rollover appearance. When the user clicks an unselected RadioButton control, the input focus moves to the control and the button displays its false pressed appearance. When the mouse button is released, the button displays the true state appearance. The previously selected RadioButton control in the group returns to its false state appearance.
coding:
<?xml version=”1.0″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml”>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.ItemClickEvent;
// Event handler function to display the selected button
// in an Alert control.
private function handleCard(event:ItemClickEvent):void {
if (event.currentTarget.selectedValue == "AmEx") {
Alert.show("You selected American Express")
}
else {
if (event.currentTarget.selectedValue == "MC") {
Alert.show("You selected MasterCard")
}
else {
Alert.show("You selected Visa")
}
}
}
]]>
</mx:Script>
<mx:Panel title=”RadioButtonGroup Control Example” height=”75%” width=”75%”
paddingTop=”10″ paddingLeft=”10″>
<mx:Label width=”100%” color=”blue”
text=”Select a type of credit card.”/>
<mx:RadioButtonGroup id=”cardtype” itemClick=”handleCard(event);”/>
<mx:RadioButton groupName=”cardtype” id=”americanExpress” value=”AmEx”
label=”American Express” width=”150″ />
<mx:RadioButton groupName=”cardtype” id=”masterCard” value=”MC”
label=”MasterCard” width=”150″ />
<mx:RadioButton groupName=”cardtype” id=”visa” value=”Visa”
label=”Visa” width=”150″ />
</mx:Panel>
</mx:Application>