Join Login


Video Tutorials
Blog



Full Color Brochures from PrintPlace.com

Radio Button Component


By: RiverCityGraphix      Views: 3298      Share: Bookmark and Share

In this tutorial, you will learn how to use the Radio Button Component in Flash CS4.

The radio button component can come in very handy when creating forms in Flash. The radio button can be toggled on and off to signify a selection and then retrieved to do any task. In the case of this tutorial I made a bit of a quiz/game with right and wrong answers. This method could easily be adopted into a poll or other application in Flash. The most frequent use of this component that I see on the web is a male/female selection for sign-up forms. It has a lot of applications and is therefore a valuable component to know how to use.

ActionScript 3.0
import fl.controls.RadioButtonGroup;
var group:RadioButtonGroup = new RadioButtonGroup("My Question");

red.group = group;
green.group = group;
blue.group = group;
orange.group = group;

red.label = "Red";
green.label = "Green";
blue.label = "Blue";
orange.label = "Orange";

submit.label = "Submit";
submit.addEventListener(MouseEvent.CLICK, submitcolor);

function submitcolor (event:MouseEvent):void{
if (group.selection == null) {
return;
}
if (group.selection.label == "Blue") {
mytxt.text = group.selection.label + " is my favorite color. Great job!";
} else {
mytxt.text = group.selection.label + " is not my favorite color. Try again.";
}
}




Free Source Files Zip

Royalty Free Images