5 Replies Latest reply on Feb 16, 2007 7:57 AM by kglad

    Array from loop

    aniebel Level 2
      I am starting to "get" for loops and arrays but for some reason I have a mental block with this. grrrr....

      I need to generate a new array from the first loop and populate it from the nested loop. If I trace the array "aPics" it does, in fact do this on each iteration of the outter loop but I can't figure out how to save these as named arrays to use elsewhere in my script.

      Any help?


        • 1. Re: Array from loop
          kglad Adobe Community Professional & MVP
          did you instantiate aPics? try:

          • 2. Re: Array from loop
            aniebel Level 2
            Hi kglad, thanks. Yeah, I had aPics instantiated. As the code stands, after each iteration of i, I trace aPics and the correct information shows in the trace window. I want one image attribute from each node of the year to populate an array for each year. So I will have an array of year image arrays.

            2002[image1.jpg, image2.jpg, image3.jpg], 2003[image1.jpg, image2.jpg], 2004[image1.jpg, image2.jpg, image3.jpg, image4.jpg]

            Is this do-able? I need to be able to call each of the indexes from the big array so that I can use the elements within. What I can't figure out how to do is populate the sub-arrays. The only thing that happens is that each iteration of the i loop appends what was already there from the last iteration. So if I had two images from 2002, when the 2003 loop occurs, I get 2002 AND 2003 images added to the array.

            Sorry for the novel. I hope this explains better.
            • 3. Re: Array from loop
              kglad Adobe Community Professional & MVP
              you can create an array of arrays. to create an array of years, each element of which contains an array of pics, you can use:

              • 4. Re: Array from loop
                aniebel Level 2
                Thanks, kglad! I didn't realize one could access nested arrays with that syntax. Always learning something new with you at the helm. :)
                • 5. Re: Array from loop
                  kglad Adobe Community Professional & MVP
                  you're welcome.