3 Replies Latest reply on Jun 11, 2008 6:59 AM by martinjamesroberts1

    FOR problem

    martinjamesroberts1 Level 1
      Hi there,

      I have some code which I have attached below, I'm trying to use a for loop to load in a large version of each of twelve images - only thing is ("img/bigPic" + i) is returning a value of 13 for all buttons when I need it to return the same value as ['picBox' + i]

      Thanks in advance
        • 1. Re: FOR problem
          Greg Dove Level 4
          The issue is that the onRelease handler loadMovie call is only evaluated when it is run... by which time i is 13 because the loop has finished.

          I would try it more like this (not tested):
          • 2. Re: FOR problem
            martinjamesroberts1 Level 1
            Hi GWD,

            Thanks for the quick reply... I have tried this code and it still returns a value of 13 or undefined... I have attached the latest code for your perusal... I added a trace function, and have discovered when it is placed outside of the onRelease function it traces one through twelve as you would expect but when inside the onRelease function it traces 13 or undefined dependant on the code used?! Also if I put the actual image number (i.e bigPic1.jpg) it loads in fine!! I can see what you were getting at with the previous post and I certainly expected it to work, although I have tried this and also placing "this['picBox'+i].i = i;" in the same place. Both returned undefinied number!

            Thanks again
            • 3. Re: FOR problem
              martinjamesroberts1 Level 1
              Now it works amazingly. I tried it again and you were right all along... I wonder why it did that!? Anyway many many thanks to you GWD!! Here is the code!