# Gallery help

**URL:** <https://forum.kirupa.com/t/gallery-help/260315>\
**Category:** Uncategorized\
**Created:** [May 14, 2008, 12:10pm UTC](https://forum.kirupa.com/t/gallery-help/260315 "2008-05-14T12:10:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![james182](https://avatars.discourse-cdn.com/v4/letter/j/278dde/32.png) [@james182](https://forum.kirupa.com/u/james182)\
**Post date:** [May 14, 2008, 12:10pm UTC](https://forum.kirupa.com/t/gallery-help/260315/1 "2008-05-14T12:10:50Z")

</div>

i am trying to do a gallery like the dope awards ( [http://www.dopeawards.com](http://www.dopeawards.com) ).  
the gallery section is the only thing i am try to do.

my code is below, am stuck on getting it working right.

please help, thank you. 👼

library contains:

- galleryItem (linkage name)
- galleryHolder (empty movie clip on stage)
- btns (btnPrev & btnNext)

```auto

var images:Array = new Array("one","two","three","four","five","six","seven","eight","nine","ten");
// Global Variables
//var images = new Array();
var currPage = 1;
var imagesPerPage = 3;
var imagesPerRow = 3;
var imageWidth = 100;
var imageHeight = 100;
var imagePadding = 10;
var imageCount = images.length;
var pageCount = Math.floor(imageCount/imagesPerPage);
var baseGal = _root.galleryHolder;
/* ------------------------------------------
TRACES
------------------------------------------ */
trace("/* ------------------------------------------");
trace("Image Count: "+imageCount);
trace("Page Count: "+pageCount);
trace("------------------------------------------ */");

btnNext.onRelease = function(){
    nextPage()
}
btnPrev.onRelease = function(){
    prevPage()
}
function nextPage() {
    if (currPage>pageCount) {
        return false;
    } else {
        trace("Page "+currPage);
        for (i=0; i<imagesPerPage; i++) {
            image = images[i+(currPage*imagesPerPage)];
            addImage(i);
        }
    }
    currPage++;
}

function prevPage() {
    if (currPage == 1) {
        return false;
    } else {
        trace("Page "+currPage);
        for (i=0; i<imagesPerPage; i++) {
            image = images[i+((currPage-1)*imagesPerPage)];
            addImage(i);
        }
    }
    currPage--;
}

function addImage(count) {
    // add movieclip with set positions above
    //movieClipContainer = createEmptyClip();
    
    padding = (count == 0) ? 0 : imagePadding;
    baseGal.attachMovie("galleryItem", "galleryItem"+i, baseGal.getNextHighestDepth());
    baseGal["galleryItem"+i]._x = (count%imagesPerRow*baseGal["galleryItem"+i]._width)+padding;
    baseGal["galleryItem"+i]._y = (Math.floor(count/imagesPerRow)*baseGal["galleryItem"+i]._height)+padding;
    trace("--+ count "+count);
        
    // if images exists add it
    // preload thumbnail
    //preloadImage(images(count),movieClipContainer);
}

function preloadImage(imagePath, containerMovie) {

    containerMovie.loadMovie(imagePath);
    containerMovie.onEnterFrame = function() {
        filesize = picture.getBytesTotal();
        loaded = picture.getBytesLoaded();

        // once loaded hide preloader spinner wheel

        // show image
    };
}

// flash buttons

// load xml and push each image into images array

```
