3 Replies Latest reply on May 7, 2008 7:02 AM by clbeech

    variable not working

      I'm trying to place thumbnail images on the stage using looping, so I can change out the thumbnails easily later on. I've copied and pasted script I used from a similar project, only the images were placed horizontally, rather than vertically. Using traces, I've figured out that the problem is in the yStart variable. Here is my code:

      var xSpace:Number=280;
      var yStart:Number=175;
      var spacing:Number=30;

      var i:Number;
      for (i=1; i<printThumbArray.length; i++) {
      _root.printThumbHolder_mc.attachMovie("printThumb"+i+"_mc","printThumb"+i+"_mc", 500+i);

      _root.printThumbHolder_mc["printThumb"+i+"_mc"]._y=yStart;
      _root.printThumbHolder_mc["printThumb"+i+"_mc"]._x=xSpace;
      yStart+=_root.printThumbHolder_mc["printThumb"+i+"_mc"]._height+spacing;
      //trace(yStart);
      }

      Can anyone help me?

      Thanks!
        • 1. Re: variable not working
          Ned Murphy Adobe Community Professional & MVP
          What is the problem you are having... that is, what isn't happening? I tried your code with two simple rectangle movieclips and it worked as I think you expect it to. The only thing I changed was the loop's printThumbArray, since I don't know what that is... I just replaced it with a fixed number (3) based on the 2 pieces I had. Since it's not defined in your sample code, maybe you just missed including it?
          • 2. Re: variable not working
            Level 1
            printThumbArray is an array populated with thumbnail images. Right now, there are 11 images in the array. The loop is supposed to place the thumbnail images in an empty movie clip, printThumbHolder_mc. The problem is that the thumbnail images are not being placed on the stage. The yStart variable is not working. When I did a trace, yStart shows 175, the starting point, and then is either undefined or NAN. Any thoughts?

            Thanks for the help!
            • 3. Re: variable not working
              clbeech Level 3
              i believe there may be simpler way to do this - as well as there being a small issue in the loop with starting at the array index of 1 - also if the images are listed in the array then you do not need to use the 'name' string in the method and can use the array value instead. additionally make sure that the linkage ID is set to the string name given to the clip in the Library. something more like the following: