Dynamic Pageing?!

Hi there. Keep up the good work!
I’m trying to customize an xml photo gallery and need someone to help me with the pageing. When there are more pictures on the stage than it can hold I need Flash to generate page numbers and send the other pictures on a different page. Anyone who can help? Thanks in advance!

Here is the code:

var thumb_spacing = 76;
var thumb_height = 60;

function GeneratePortfolio(portfolio_xml)
{
var portfolioPictures = portfolio_xml.firstChild.childNodes;

var positionX = 0;
var positionY = 0;
for (var i = 0; i < portfolioPictures.length; i++)

{
var currentPicture = portfolioPictures*;

    var currentThumb_mc = menu_mc.createEmptyMovieClip("thumbnail_mc"+i,i);
    if (positionX > 260)
    {
        positionX = 0;
        positionY += thumb_height;
    }
    currentThumb_mc._x = positionX;
    currentThumb_mc._y = positionY;
    positionX += thumb_spacing;
    
    currentThumb_mc.createEmptyMovieClip("thumb_container",0);
    currentThumb_mc.thumb_container.loadMovie(currentPicture.attributes.thumb);
    
    currentThumb_mc.image = currentPicture.attributes.image;
    
    currentThumb_mc.onRelease = function()

{
image_mc.loadMovie(this.image);
}
currentThumb_mc.onRollOver = function ()
{
this.attachMovie(“rollit”, “newroll”, 1);
this.newroll._alpha = 40;
}
currentThumb_mc.onRollOut = function ()
{
this.newroll.removeMovieClip();
}
}
}

// xml object for xml content
var portfolio_xml = new XML();
portfolio_xml.ignoreWhite = true;
portfolio_xml.onLoad = function(success)
{
if (success) GeneratePortfolio(this);
else trace(“Error loading XML file”);
}
// load
portfolio_xml.load(“portfolio2.xml”);