Positioning objects from array into Rows And Columns

  • bAb0oN
  • Born
  • Born
  • bAb0oN
  • Posts: 2

Post 3+ Months Ago

Hi there :) I'd like to ask for some help with getting my objects(photo thumbnails) into a few lines of rows and columns. Say I have 10 photos and I'd like to make 2 lines of five thumbnails like:

Photo01 Photo02 Photo03 Photo04 Photo05
Photo06 Photo07 Photo08 Photo09 Photo10

I've looked for similar examples for ways to tweak the code but still I couldn't get it right. Below is the few ways I did that kinda come close.

========Try01-Messy========

Code: [ Select ]
    col = 0;
    row = 0;
    for (var i = 0; i<NPICS; i++, col++) {
        var mc:MovieClip = thumbs_mc.createEmptyMovieClip("mc"+i, i+1);
        col = i;
        if (col%5 == 0) {
            row++;
            col = 1;
        }
        mc._x = col*THUMBW;
        mc._y = row*THUMBH;
    }
  1.     col = 0;
  2.     row = 0;
  3.     for (var i = 0; i<NPICS; i++, col++) {
  4.         var mc:MovieClip = thumbs_mc.createEmptyMovieClip("mc"+i, i+1);
  5.         col = i;
  6.         if (col%5 == 0) {
  7.             row++;
  8.             col = 1;
  9.         }
  10.         mc._x = col*THUMBW;
  11.         mc._y = row*THUMBH;
  12.     }


Results in:
Photo02 Photo03 Photo04 Photo05
Photo06 _____________________Photo07 Photo08 Photo09
Photo10

So, Photo01 is missing since Photo02 is on top of it. After Photo06, there are gaps(about 4 thumbs).

========Try02-Skipper========
Code: [ Select ]
for (var i:Number = 0; i < NPICS; i++) {
       var mc:MovieClip = thumbs_mc.createEmptyMovieClip("mc"+i, i+1);
         if (i<=2){
             mc._x = MARGIN + i*(MARGIN + THUMBW);
             //mc._y = MARGIN;
             } else {
                 mc._x = MARGIN + i*(MARGIN + THUMBW);
                 mc._y = MARGIN + THUMBH;
                 } 
      }
  1. for (var i:Number = 0; i < NPICS; i++) {
  2.        var mc:MovieClip = thumbs_mc.createEmptyMovieClip("mc"+i, i+1);
  3.          if (i<=2){
  4.              mc._x = MARGIN + i*(MARGIN + THUMBW);
  5.              //mc._y = MARGIN;
  6.              } else {
  7.                  mc._x = MARGIN + i*(MARGIN + THUMBW);
  8.                  mc._y = MARGIN + THUMBH;
  9.                  } 
  10.       }


Results in:
Photo 01 Photo02 Photo 03
______________________Photo04 Photo06 Photo07 Photo08 Photo09 Photo10

So, on the second line 4 thumbs spaces are skipped and it won't make a new line after that.

Any help on this would be appreciated :) Thank you.


-Mer
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

your second block is almost right but you could just use a counter to say if there are more than 5 photos in the row start the x and y over at a new location
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

cute. you need to take a programming class
  • bAb0oN
  • Born
  • Born
  • bAb0oN
  • Posts: 2

Post 3+ Months Ago

If you'd be my tutor :)
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

hmmm, that might take a long time and i don't have it. I'm working you know, and you also know that a cigarette shortens one's life with 7 minutes, a bottle of beer with 14 minutes .... and a day of work with 8 hours. Now you do the maths and see which one is killing u faster :D

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: No registered users and 10 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.