3 Replies Latest reply on Jun 27, 2006 6:56 AM by LucaLT

    Dynamic MovieClip "Grid"

    LucaLT Level 1
      Hello everyone!

      It's been i while since my last post, I wish I could be more active in this forums, but Flash it's just my sparetime activity, much like crosswords and since I'm bored here on vacation I decided to start a new simple project.
      I want to create a PhotoGallery application, nothing very complicate, but still a bit challenging (at least for me!!). Basically I want a "grid" of thumbnails from which I can enlarge the selected picture. I was able to create the "grid" using two "for" statements (one for the rows and one for the colums), plus I experimented the tween class, which I never used before. I have had no problem creating the "grid" because I hard coded the values for rows and columns, but a true photogallery application has to use an external XML file don't you think?
      Well, I thought it was a piece of cake, but the "double" for statement kinda block me. First of all, I haven't figure out how to hide the thumbnails that are in excess. For example, if I have 16 pictures and I set a fixed number of columns (Let's say 5), I would need 4 rows, but the last one has to have just one thumbnail on the first columns and not an entire line of 5. Second of all, I can't loop the XML nodes inside the "double" for stament because obviously I get wrong values. Could anyone give me some hints in order to " fix" these problems?
      Sorry, for the long post, I hope you haven't fallen asleep!
      Thank you in advance for any help!!


      Test.fla
        • 1. Re: Dynamic MovieClip "Grid"
          squipple Level 1
          What I might do here is instead of making a loop for rows/columns, set up a loop for the entire group and code it to how you want them positioned.
          So, if you want rows of 4, just test to see if the current for variable is divisible by 4, and move the next clip to _x =0 (or whatever your beginning x position is) and adjust the y position accordingly.
          Just one of many ways around the double for loop.
          • 2. Re: Dynamic MovieClip "Grid"
            LucaLT Level 1
            Thank you very much for your reply. I understand the theory behind what you are saying; It makes perfectly sense. The problem is that it doesn't work. I'm sure I'm missing something and probably I didn't get exactly what you meant. I tried with this code:

            for (var i = 0; i<10; i++) {
            matrix = grid.thumb.duplicateMovieClip("thumb"+i, i+1);
            matrix._x = i*25;
            if (i%4) {
            matrix._x = 0;
            matrix._y = 80;
            }
            }
            the fourth thumb the goes down, but the other just stay on top of each other in the new line. I tried to add a new _x value, but then it would ignore the if statement and make a straight line of clips. Would be so kind to post an example?

            Thank you again!

            • 3. Re: Dynamic MovieClip &quot;Grid&quot;
              LucaLT Level 1
              Is there anyone else who is willing to help? I'm sorry but I really can't figure that out without using a double for statement.
              Thanks in advance.