Radiobutton Control

By pandimalar

Definition:

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.
You define a RadioButton control in MXML by using the <mx:RadioButton> tag .
For each RadioButton control in the group, you can optionally define an event listener for the button’s click event.

Source Code:
<?xml version=”1.0″?>
<!– controls\button\RBEvent.mxml –>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml”>
<mx:Script>
<![CDATA[

import flash.events.Event;

private function handleAmEx(event:Event):void {
// Handle event.
myTA.text="Got Amex";
}

private function handleMC(event:Event):void {
// Handle event.
myTA.text="Got MasterCard";
}

private function handleVisa(event:Event):void {
// Handle event.
myTA.text="Got Visa";
}
]]>
</mx:Script>

<mx:RadioButton groupName=”cardtype”
id=”americanExpress”
label=”American Express”
width=”150″
click=”handleAmEx(event);”/>
<mx:RadioButton groupName=”cardtype” id=”masterCard” label=”MasterCard” width=”150″ click=”handleMC(event);”/>
<mx:RadioButton groupName=”cardtype” id=”visa” label=”Visa”  width=”150″ click=”handleVisa(event);”/>
<mx:TextArea id=”myTA”/>
</mx:Application>

Thanks with Regards,
Pandimalar A

Leave a Reply