how would I do this?
duplicate a movie clip, let’s say 15 times, and after the 5th clip a new column is created, on up to the 15 clips making 3 total columns of 5?
Thanks
how would I do this?
duplicate a movie clip, let’s say 15 times, and after the 5th clip a new column is created, on up to the 15 clips making 3 total columns of 5?
Thanks
MX I presume?
what youd do is use loops. One loop to loop through your columns, and one to loop through your rows. On the first loop going through a column, you loop through your rows so that first column position is populated with the number of rows you have. So one loop goes up and down and the other accross, making the grid.
In order to actually space out your grid, you need to base your poisition on your grid position (row/column) and a spacing value. Heres an example:
spacing = 10;
depth = 0
for (x = 0; x < 3; x++){
for (y = 0; y < 5; y++){
this.attachMovie("clip", "clip"+depth, depth++, {_x:x*spacing, _y:y*spacing})
}
}
this sets clips attached clips ffrom the library item “clip” 10 pixels apart in a 3 (wide) by 5 (down) column. The argument after the depth is the init object which lets you set properties for the newly attached clip, in this case we are setting the _x and _y to be the x and y values of the loops (each looping through a succesively higher number) times the spacing which spaces it out along a grid.
Yea… that’s pretty cool. I thought it was something like that but I didn’t know how to write it (I had my second for loop in the wrong spot). I’m going to mess with it a little bit. I need to make it duplicate a movieclip for each childNode it finds in an XML doc and make as many columns of 5 as it needs to complete the task. So I need to get the “3” you have for the X to be dynamic somehow. Can i use length of the total children divided by 5 to get that number?
yeah you can replace 3 with anything you want. I dont know what the dividing by 5 does though?
By dividing the total number childNode.length (10) by how many movieclips I want in a column (5) I’ll get how many columns I need (2). These are just numbers I’m pulling out of the air right now so I obviously wouldn’t need to calculate it like thisfor static numbers. But as that XML childNode number grows so must the number of columns, hence the dividing by 5.
Thanks Senocular
:: Copyright KIRUPA 2024 //--