4 Replies Latest reply on Nov 27, 2006 11:53 AM by crazyjoemilan

    defining onRelease in a loop.

    crazyjoemilan Level 2
      So I'm building a dynamic menu where the button actions change for each item that is listed. Now I think I could do this while writing classes, but I'm rushing to get it done, I'd rather just script functions for it. However, when I run a for loop, it sets all values of all buttons (see code) to the value+1 of i. Thus, each button has the same action, and unless I manipulate i-- doesn't work. Anyway, my real question is whether LIFE cereal is a healthy cereal or a sugary one.

      Second to that, I need to know how I would do this.
      for(i=1;i<someOtherVariable;i++) {
      _root.["myButton"+i].onRelease = function() {
      //a bunch of functions that use i to opperate correctly
      }
      }

      Can you help me?