Incorporating an Array with Xml images

Hi there.

I have an evolving script and my actionscript knowledge is limited. How would I incorporate xml with the following code. I have a menu that can be navigated by pressing the down or up keys, and everytime the next button gets activated I want the corresponding xml image to appear. as of right now when I push the ‘down’ or ‘up’ it fails to bring up the corresponding image. This is the result of my lack of knowledge on arrays and how they work (you can see I attempted to assign each xml image to the buttons assigned id, needless to say the array cycles through those images each time the buttons are activated, so I’m not really sure where to go from here. Any help will be greatly appreciated. This is my code I have so far:


stop();

xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
/////////////////////////////////////



var currentButtonId:Number = 0;
var buttons:Array = [jms_btn, tkno_btn, kofi_btn, bolle_btn, don_btn, nchil_btn];

function buttonRelease() {
    for(var i:Number = 0; i < buttons.length; i++) {
        if(this.id == buttons*.id) {
            currentButtonId = i;
            buttons*.gotoAndStop(2);
            buttons*.enabled = false;
            trace(i);
        } else {
            buttons*.gotoAndStop(1);
            buttons*.enabled = true;
        }
    }
} 

jms_btn.id = 1;
tkno_btn.id = 2;
kofi_btn.id = 3;
bolle_btn.id = 4;
don_btn.id = 5;
nchil_btn = 6;
jms_btn.onRelease = buttonRelease;
tkno_btn.onRelease = buttonRelease;
kofi_btn.onRelease = buttonRelease;
bolle_btn.onRelease = buttonRelease;
don_btn.onRelease = buttonRelease;
nchil_btn.onRelease = buttonRelease;
jms_btn.gotoAndStop(1)
tkno_btn.gotoAndStop(1)
kofi_btn.gotoAndStop(1)
bolle_btn.gotoAndStop(1)
don_btn.gotoAndStop(1)
nchil_btn.gotoAndStop(1)


function checkButtonLimit()  {
    // Max
    if(currentButtonId > buttons.length - 1)  {
        currentButtonId = buttons.length - 6;
    }
    // Min
    if(currentButtonId < 0)  {
        currentButtonId = 5;
    }
}

function buttonCall()  {
if(currentButtonId = 1) {
	firstImage();
}
if(currentButtonId = 2) {
	secondImage();
}
if(currentButtonId = 3) {
	thirdImage();
}
if(currentButtonId = 4) {
	fourthImage();
}
if(currentButtonId = 5) {
	fifthImage();
}

}

var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
    switch(Key.getCode()) {
        case Key.DOWN :
            currentButtonId++;
            break;
        case Key.UP :
            currentButtonId--;
            break;
    }
    checkButtonLimit();
    buttons[currentButtonId].onRelease();
	buttonCall()
}

Key.addListener(keyListener);

bar._visible = false;
descrip.onEnterFrame = null;
titletxt.onEnterFrame = null;

function loadXML(loaded) {
	if (loaded) {
		xmlNode = this.firstChild;
		image = [];
		header = [];
		description = [];
		
		total = xmlNode.childNodes.length;
		for (i=0; i<total; i++) {
			image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
			header* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
			description* = xmlNode.childNodes*.childNodes[2].firstChild.nodeValue;
		}
	} else {
		content = "file not loaded!";
	}
}

picture._x = 50
picture._y = 400
/////////////////////////////////////
if (p==undefined) {
	p=-1;
}

this.onEnterFrame = function() {
	filesize = picture.getBytesTotal();
	loaded = picture.getBytesLoaded();
	bar._visible = true;
	if (loaded != filesize) {
		bar._xscale = 100*(loaded/filesize);
	} else {
		bar._visible = false;
		if (picture._alpha<100) {
			picture._alpha += 8;
		}
	}
};
function firstImage() {
	if (loaded == filesize) {
		picture._alpha = 0;
		picture.loadMovie(image[0], 1);
		titletxt.text = header[0];
		descrip.text = description[0];
		picture_num();
	}
}
function secondImage() {
	if (loaded == filesize) {
		picture._alpha = 0;
		picture.loadMovie(image[1], 1);
		titletxt.text = header[1];
		descrip.text = description[1];
		picture_num();
		trace( "second" );
	}
}
function thirdImage() {
	if (loaded == filesize) {
		picture._alpha = 0;
		picture.loadMovie(image[2], 1)
		titletxt.text = header[2];
		descrip.text = description[2];
		picture_num();
		trace( "third" );
	}
}
function fourthImage() {
	if (loaded == filesize) {
		picture._alpha = 0;
		picture.loadMovie(image[3], 1);
		titletxt.text = header[3];
		descrip.text = description[3];
		picture_num();
		trace( "fourth" );
	}
}
function fifthImage() {
	if (loaded == filesize) {
		picture._alpha = 0;
		picture.loadMovie(image[4], 1);
		titletxt.text = header[4];
		descrip.text = description[4];
		picture_num();
		trace( "fifth" );
	}
}
function sixthImage() {
	if (loaded == filesize) {
		picture._alpha = 0;
		picture.loadMovie(image[5], 1);
		titletxt.text = header[5];
		descrip.text = description[5];
		picture_num();
		trace( "sixth" );
	}
}
function picture_num() {
	current_pos = p;
	pos_txt.text = current_pos+" / "+total;
}