array.push not cumulative?
I have an array ("parentArray") assigned as a data provider for a dropdown as so:
_global.parentArray = new Array();
_level0.parentCombo.dataProvider = parentArray;
I also have a main data array ("mainArray") which I use to store everything:
_global.mainArray = new Array();
mainArray = [
["", "", "", "", "", "", "", ""],
["ItemA", "", "", "", "", "", "", ""],
["", "", "", "", "", "", "", ""],
["ItemB", "", "", "", "", "", "", ""],
["ItemC", "", "", "", "", "", "", ""],
["", "", "", "", "", "", "", ""],
["", "", "", "", "", "", "", ""]
];
Now, anytime the mainArray is change, I want to rebuid the dropdown list. So, I proceed to clear the existing array, and then find all non-blank [0] column values and add them to the parentArray.
rebuildDropdown () {
parentArray.length = 0;
for (var i = 0; i < 6; ++i) {
if (mainArray[i][0] <> "") {
parentArray.push(mainArray[i][0]);
trace("mainArray val: "+mainArray[i][0]);
}
}
}
But, even with values in the mainArray, the dropdown only ever lists the last var pushed to the parentArray - not all three as should be in this case.
The trace shows all three values correctly. Any ideas? :0
Ahhhk!