3 Replies Latest reply on Feb 12, 2007 1:42 PM by kglad

    Make a Variable a Constant?

    SlowX Level 1
      I have a bunch of MCs that I want to each have the a function assigned:
      for (i=0; i<7; i++) {
      this["genericMC_" + i].onPress = function() {
      doThatThingYouDo(i);
      }
      }

      Only thing is that I want the value of "i" at the time it runs to be assigned. So for "genericMC_1" I want the onPress function to be doThatThingYouDo(1), for "genericMC_3" I want the onPress function to be doThatThingYouDo(3), etc. Instead, they all get doThatThingYouDo(7).
      Yuck.

      Any suggestions?