3 Replies Latest reply on Aug 30, 2010 1:24 PM by Ned Murphy

    Variable references to objects

    Matt Schneck

      OK, I've got a 15x3 grid of dynamic text fields in an object called "textbox" that I want to reference through a for loop, so I don't have to have 45 lines of code for assigning stuff to those fields.


      I have each dynamic field named by their placement in the grid, so, c0a, c0b, c0c, c1a, c1b, c1c, etc.

      I can also name them c00, c01, c02, if necessary.


      I tried:


      for (i=0; i<15; i++) {

         textbox.c[i]a.text = "Cell " + i + " A";

         textbox.c[i]b.text = "Cell " + i + " B";

         textbox.c[i]c.text = "Cell " + i + " C";



      but that gives me a syntax error.


      I also tried naming them c00, c01, c02, c10, c11, c12, etc., so I could do a double nested loop:


      for (i=0; i<15; i++) {

           for (n=0; n<3; n++) {

                textbox.c[i][n].text = "Cell " + i + n;




      but that gives me a syntax error too.



      So, is there a way to access all of these with a for loop, or am I going to have to do it the long way?



      (I'm using AS2)