6 Replies Latest reply on May 17, 2007 6:55 AM by MarkCPainter

    Array Name

    NoNameNoPackDrill
      I need to be able to access an array through an indirect reference to not the index, but the name of the array.

      Any help greatly appreciated.
        • 1. Re: Array Name
          kglad Adobe Community Professional & MVP
          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?
          • 2. Array Name
            NoNameNoPackDrill Level 1
            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[0][0] 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!
            • 3. Re: Array Name
              kglad Adobe Community Professional & MVP
              if var1 and var2 contain strings that you want to concatenate to form a _global array use:

              • 4. Re: Array Name
                NoNameNoPackDrill Level 1
                kglad

                Thank you for your quick and complete response to my problem
                • 5. Re: Array Name
                  kglad Adobe Community Professional & MVP
                  you're welcome.
                  • 6. Re: Array Name
                    MarkCPainter
                    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?

                    Thanks,
                    Mark.