This content has been marked as final. Show 6 replies
you can have an indexed array and you can have an associative array. you can use a variable to reference the name of the array and an variable to reference the index or associated key of the array.
now, what is it that you want to do?
I want to do:
arrayName = "_global."+ var1 + var2;
so that arrayName now contains a reference to an array name based on the values of var1 and var2.
A trace of arrayName seems to contain the correct name, but when I access arrayName I get 'undefined', although the data is returned if I 'hard code' the actual array name into the same instruction. I have tried creating the array in the main line, so that I don't need the _global. - makes no difference. If, as you say you can reference an array through a variable that contains its name, I am clearly not doing it right!
if var1 and var2 contain strings that you want to concatenate to form a _global array use:
Thank you for your quick and complete response to my problem
I think this is exactly what I need but I can't get it to work.
I have some arrays called A00, A01 A02...A11, A12 etc. The first number comes from the index of the chosen item in one combo box, the second number comes from the index of the selected item in a second combo box. So the first item in combo box one returns an index of 0 and the fourth item in combo box two returns an index of 3, so I want to acces array A03.
If I code:
var SelectedArray:Array = A03;
it will work but when I try and create a string by:
var MakeArrayString:String = "A"+ String(ComboOne.selectedIndex) + String(ComboTwo.selectedIndex);
I get an error. The MakeArrayString holds the correct value (namely A03) but I can't find a way of using this to reference the array.
Can anyone offer any ideas?