Solved

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

Posted on 2008-06-10
2
943 Views
Last Modified: 2013-11-11
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
0
Comment
Question by:Abyssmal
2 Comments
 
LVL 12

Expert Comment

by:williamcampbell
ID: 21755359
Better to use a RadioButton group instead you get that functionality for free.
0
 
LVL 12

Accepted Solution

by:
SamuelRostol earned 500 total points
ID: 21757232
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!
Kindly,
Samuel
// 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 (_e.target != aCheckBoxes[i]) 
		{
			aCheckBoxes[i].selected = false;
		}
	}
}

Open in new window

Checkbox.zip
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How do I change text in a Flash (FLA, SWF) file? 3 998
Can't find all of the preferences on Flash Pro 2 486
Accessing Live Dynamic Stream 6 196
Adobe Flash Free Transform Tool 2 136
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now