I have a 5 checkboxes and what I like to do is to be able to push the selected checkboxes to an array. So I have coded to check if the selected checkbox already exist in the array, if it doesn't then the selected value is pushed. The way I think I should go about is to first have the user select their answer and then there should be a submit button which will finalize all the selected values and the check if any of these values already exist in the array, and if they don't then push them into the array.
Here is my code:
var cbArr:Array = new Array();
var gRoot = this._root;
var main:MovieClip = gRoot.createEmptyMovieClip('mc', this.getNextHighestDepth());
var mObj:Object = new Object();
mObj.click = function(e:Object)
//CHECK TO SEE IF THE SELECTED VALUE ALREADY EXIST IN TH ARRAY
if(cbArr.indexOf(e.target._name == -1))
e.target.label = "UNSELECTED";
for(var i:Number = 0; i < 6; i++)
main.attachMovie('CheckBox', 'cb'+i, i);
main['cb'+i]._x = 100;
main['cb'+i]._y = (150 + (i * 25));
main['cb'+i]._name = "cb" + i;
1. what's the problem with your current approach?
2. can user's deselect checkboxes and, if yes, do you want to then remove them from the array?