Gallery help

i am trying to do a gallery like the dope awards ( 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. :angel:

library contains:

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


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