4 Replies Latest reply on Jan 20, 2011 6:54 AM by kglad

    Loop Fails to Execute Code But List of Commands Works - Baffled

    Kwangle Level 1

      Hi All,

       

      I've got 13 movieclips that all run a function (setNames) contained in a child object (namer) it contains. The function displays text in a dynamic text box.

       

      I've set them up with the instance names mark0 > mark12 so I can target them with a loop and array notation which is something I often use. But the loop sometimes doesn't work, however a list of 13 separate lines of code works fine. Am I overloading Flash with too much code commands at once, and is there a way around this?

       

      This doesn't work...

       

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

      //sets names

      this["mark"+i].namer.setNames();

      }

       

      ...but doing it manually works fine:

       

      mark0.namer.setNames();

      mark1.namer.setNames();

      mark2.namer.setNames();

      mark3.namer.setNames();

      mark4.namer.setNames();

      mark5.namer.setNames();

      mark6.namer.setNames();

      mark7.namer.setNames();

      mark8.namer.setNames();

       

      mark9.namer.setNames();

      mark10.namer.setNames();

      mark11.namer.setNames();

      mark12.namer.setNames();

       

      Strangely, the following code does work:

       

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

      //clears names

      this["mark"+i].namer.phs = 1;

      }

       

      I have checked the code carefully and tested the code with trace actions but can't see the problem. Any ideas?