# Controlling pagination with arrays

**URL:** https://forum.kirupa.com/t/controlling-pagination-with-arrays/255806
**Category:** Uncategorized
**Created:** [March 27, 2008, 6:04am UTC](https://forum.kirupa.com/t/controlling-pagination-with-arrays/255806 "2008-03-27T06:04:00Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![pixel\_streamer](https://avatars.discourse-cdn.com/v4/letter/p/a8b319/32.png) [@pixel\_streamer](https://forum.kirupa.com/u/pixel_streamer)
#### Post date: [March 27, 2008, 6:04am UTC](https://forum.kirupa.com/t/controlling-pagination-with-arrays/255806/1 "2008-03-27T06:04:00Z")

</div>

How do I create pages of thumbnails based on a total image count?

I’m using a loop to populate an image holder mc, (imageHolder) I create 80 (arbitrary) empty movie clips and push them into a large array. That part works fine.

Using the length of the large array (newImages), I loop through the clips in that to shift the larger array into smaller ones, incrementally named (pgArray). Since imagesPerPage is 10, I expected to have 10 arrays that contained the empty mcs, but something has gone wrong. Here’s my pagination function:

```auto

function cullArray():Void {
    trace("cullArray called");
    var allImgCount:Number = newImages.length;
    for (var k:Number = 0; k < Number(allImgCount / imagesPerPage); k++) {
        var pgArrayName:String = String("pageArray" + k);
        var pgArray:Array = [];
        for (var j:Number = 0; j < imagesPerPage; j++) {
            var img:Object = newImages.shift();
            trace("img name:	" + img);
            pgArray.push(img);
        }
        trace("Here are the images on the " + k + "st page" + " (" + String(pgArrayName) + ")
");
        trace("	" + pgArray);
    }
    trace("cullArray ended");
}

```

Can someone help me out? I think I’m referencing the strings and the arrays incorrectly. Thanks!

I found a solution after a while, but it probably needs cleaning up:

> **[Creating Number Sets](https://www.kirupa.com/forum/showthread.php?t=257111)**
>
> Got a web design/development question or just want to hang out with the most awesome people on the planet? Drop on in!
