# \[Flash 8 AS 2.0\] Help in code that generate grid view of box using for loop

**URL:** https://forum.kirupa.com/t/flash-8-as-2-0-help-in-code-that-generate-grid-view-of-box-using-for-loop/278613
**Category:** flash
**Created:** [January 2, 2009, 5:16pm UTC](https://forum.kirupa.com/t/flash-8-as-2-0-help-in-code-that-generate-grid-view-of-box-using-for-loop/278613 "2009-01-02T17:16:53Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![honzell](https://avatars.discourse-cdn.com/v4/letter/h/8dc957/32.png) [@honzell](https://forum.kirupa.com/u/honzell)
#### Post date: [January 2, 2009, 5:16pm UTC](https://forum.kirupa.com/t/flash-8-as-2-0-help-in-code-that-generate-grid-view-of-box-using-for-loop/278613/1 "2009-01-02T17:16:53Z")

</div>

Dear all,

I am trying to use for loop to load small grey box to display in the image below.

![](http://honzell.com/box.jpg)

But i couldn’t figure out how to put in the if else condition when the col hits 7 and bring it to the next row.

Below is my if else code:

container1 = new Array();  
container1 = this.firstChild.childNodes; //drawing info from xml file  
spacing = 13;  
for (i=0; i\<container1.length; i++) {  
this.thumbHolder = thumbnails.createEmptyMovieClip(“thumbnail”+i, i);  
if (i\<7) {  
this.thumbHolder.\_x = i\*spacing;  
this.thumbHolder.\_y = 0;  
} else {  
this.thumbHolder.\_x = (i-7)\*spacing;  
this.thumbHolder.\_y = Number(thumbHolder.\_y)\*7;  
}  
}

Your help will be appreciated.

Thanks in advance.

Regards,  
Wai
