actionscript 2.0 how to only let user select 1 checkbox at a time

does flash have anything to let you check or un-check a checkbox component through actionscript?

i have 4 checkboxes and the user can only select 1, but by nature you can select multiple checkboxes.  is there any way to force the user to only select 1 at a time

i'm completely lost, i'm not too bad with actionscript but for some reason i'm just not able to figure this out
Who is Participating?
SamuelRostolConnect With a Mentor Commented:
While the RadioButton clearly is a better choice, that's not what you asked for :)

I've created a file that does just what you need. The principle is to create a loop that checks "did you just click me? If so, uncheck all the other checkboxes". This is done easily by the work of an array.

The code is attached below, and a file is added to the site. Please note that you will have to rename the file from Checkbox.txt to Checkbox.fla to be able to open it.

Good luck!
// This array contains the instance name of the different checkboxes
var aCheckBoxes :Array = [checkbox1,checkbox2,checkbox3,checkbox4];
// Adding listeners dynamically
for (var i = 0; i < aCheckBoxes.length; i++) {
	aCheckBoxes[i].addEventListener("click", uncheckOthers);
// Function for unchecking other checkboxes.
function uncheckOthers(_e:Object)
	for (var i = 0; i < aCheckBoxes.length; i++) 
		if ( != aCheckBoxes[i]) 
			aCheckBoxes[i].selected = false;

Open in new window
Better to use a RadioButton group instead you get that functionality for free.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.