A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Duplicating Movie Clips into a Grid Layout

  1. #1

    Duplicating Movie Clips into a Grid Layout

    Hi,
    I hoping someone can help me on this one... let me see if I can explain.

    I'm trying to duplicate a movie clip and adjust the _x and _y values. What's interesting here is that I need to have the duped mcs lay out in a grid... so....

    4 duplicated movie clips across then down a row and 4 across then down a row adn etc. etc.

    I'm not sure how to accomplish this, could it be a loop within a loop??

    Any thoughts would be awesome. BTW I'm using Flash 8.

    Thanks

  2. #2
    Senior Member
    Join Date
    Apr 2002
    Posts
    131
    Yes you could have a loop in a loop:

    for(y=0;y<down;y++){
    for(x=0;x<across;x++){
    duplicateMovieClip("mc","newname_"+x+y,x*20+y);
    setProperty("newname_"+x+y,_x,startx+xincrement*x) ;
    setProperty("newname_"+x+y,_y,starty+yincrement*y) ;
    }
    }

    And obviously setting variables startx,starty,xincrement,yincrement,across and down.

    Anyway I am using Flash MX so I assume it will work for you

  3. #3
    That worked exactly like I was hoping.

    Thanks xtraterrestrial.

  4. #4
    Senior Member
    Join Date
    Apr 2002
    Posts
    131
    I forgot to mention that if you have more than 20 clips down the depth parameter there (x*20+y) will make some clips not show up as they will have the same depth. To fix this issue make 20 a bigger number or make it x*down+y

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center