This ActionScript tutorial can be found, with streaming HD video at http://www.say-web.com

Radio buttons are very similar to Check boxes. They have they same properties. The difference while check boxes are stand alone, radio buttons belong to a group where only one (or none) are allowed to be be checked.

To drag and drop a radio button to stage, ask for Ctrl+F7 (windows) or Option+F7 (mac) or just go to WINDOW->COMPONENTS




By default the radio button group is called  RadioButtonGroup. I am a big fan of keeping things clear. So you should change the name of the group for a more meaningful name, yet, as long all buttons belong to same group, only one will be allowed to be checked. To see the name of the radio button of a specific group ask for WINDOW -> COMPONENT INSPECTOR



It is worth to give a tour on the Component Inspector, since all properties accessible from ActionScript. Drag and Drop as many radio buttons as you wish only one will be selected.
It is VITAL to make sure that each radio button has its own unique instance name. Instance names is the only way to access stage items through ActionScript, as usual, use meaningful names. To be able to insert an instance name click only once at one single radio button.





Note that the radio buttons comes with Labels. Unlilke regular text, if the free transform tool is applied it DOES NOT AFFECT the text format. The style has to be changed from withing ActionScript.



Now press F9 or WINDOW-> ACTIONS for the ActionScript Notepad. I strongly suggest to create a separate layer for the script them more clear, the easier it is. Here is the code for tracing the name of the target, in our case the radio button. .Once you have access to properties of the target, the sky is the limit, create switch cases for your options, and you are set to go!




HERE IS THE SOURCE CODE!

//The ActionScript 3.0 Radio Button // Avraham Saltoun // solutions at say-web dot com // FREE to USE, COPY and DISTRIBUTE

import fl.controls.RadioButton;
import fl.controls.RadioButtonGroup;
// these libraries have to be imported
// in order to access Radio button methods and properties.


//Let's Appply some formatting
//to the radial buttons
var format:TextFormat = new TextFormat;
format.size= 20;
format.font= 'tahoma';

rb1.label = "One";
rb2.label = "Two";
rb3.label = "Three";

// Now we will apply the style
//created to our labels
rb1.setStyle("textFormat", format);
rb2.setStyle("textFormat", format);
rb3.setStyle("textFormat", format);

//Event Listeners
//Will set the compiler waiting
// for a click
rb1.addEventListener(MouseEvent.CLICK, whoAmI);
rb2.addEventListener(MouseEvent.CLICK, whoAmI);
rb3.addEventListener(MouseEvent.CLICK, whoAmI);
// Note that all of them lead to the same function.



function whoAmI (event:MouseEvent){
    //This will extract the label of the clicked button
    // here called a target. Could be any component
    trace (event.target.label);
}


USEFUL LINKS: