# \[flash8\] Looping through dataset records attaching movieclips

**URL:** <https://forum.kirupa.com/t/flash8-looping-through-dataset-records-attaching-movieclips/179751>\
**Category:** flash\
**Created:** [February 22, 2006, 7:25pm UTC](https://forum.kirupa.com/t/flash8-looping-through-dataset-records-attaching-movieclips/179751 "2006-02-22T19:25:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![andersj](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@andersj](https://forum.kirupa.com/u/andersj)\
**Post date:** [February 22, 2006, 7:25pm UTC](https://forum.kirupa.com/t/flash8-looping-through-dataset-records-attaching-movieclips/179751/1 "2006-02-22T19:25:13Z")

</div>

Hi everybody !!

I have this problem:

I am using an XML connector and a dataset to pick records from an XML file. I then loop througt the dataset, attaching a movieclip for every record in a container movieclip. This works fine, i am using the following AS in the container movieclip:

\*\*//goto last data set record  
\_root.data\_ds.last();

this.addMovieClips(0);  
function addMovieClips(i) {  
while (\_root.data\_ds.hasPrevious()) {  
this.attachMovie(“targetClip”, “record”+i, this.getNextHighestDepth(), \_root.data\_ds.currentItem);  
this[“record”+i].\_x = this[“record”+i].\_x+(i\*90);  
i++;  
\_root.data\_ds.previous();  
}  
}\*\*

data\_ds is the instance name of my dataset, targetClip is the linkage name of the movieclip i attach for each record in the dataset.

This works fine, but the script attaches the movieclips in a long row, spacing 90 pixels on the x axis between every attached movieclip. What i would like to do, is for the AS to make a new row, say every 4 attached movieclips (90 pixels below the row above) so you get several rows with 4 movieclips in every row inside the container movieclip. I have fooled around with this for some time now and can´t get it to work fine.

You can see a working example here:

[[COLOR=#0000ff]http://www.128bits.net/flashdbtemp/thumbnails.html[/COLOR]](http://www.128bits.net/flashdbtemp/thumbnails.html)

I need to do this in order to create an image gallery with thumbnails. I suppose this is no match for someone experienced in AS, for that reason i would be grateful for help in this matter.

**Thank You in advance for Your help !!**
