XML Next & Prev Buttons AS3

Hey world…

One of you is my last hope. For about 3 weeks I have been stairing at this code and i cant come up with a solution. I have tried every posible thing I could think of.

What I want is “simple”, That if I click the “nxt” button, it loads the next picture in the xml. And the “prv” button goes backwards.

can someone help me. PLEEEEASE!!!

AS3 Code

///////////////////////////////////////////////////////////////////////////The Script
import fl.transitions.*;
import fl.transitions.easing.*;
import flash.display.Sprite;

var PLAYMc:playMc = new playMc();
var IMGLoader:Loader = new Loader();
IMGLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
var current_img:Number;

var x_counter:Number=0;
var y_counter:Number=0;
var columns:Number;
var p:Number=0;

var xml:XML;

var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onloaded);
loader.load(new URLRequest("Scripts/Ps.xml"));

function onloaded(e:Event):void {
	xml=new XML(e.target.data);
	var xmlData:XMLList=xml.*;

	[email protected];

	for (var i:int=0; i<xmlData.length(); i++) {
		var thumbHolder:MovieClip = new MovieClip();
		thumbHolder.graphics.lineStyle(2, 0xffffff, 1);
		thumbHolder.graphics.beginFill(0xa4a4a4);
		thumbHolder.graphics.drawRect(5, 5, 175, 94);

		var thumbOver:MovieClip = new MovieClip();
		thumbOver.graphics.beginFill(0xffffff);
		thumbOver.graphics.drawRect(6, 6, 173, 92);
		thumbOver.alpha=.0;

		var imgLoader:Loader = new Loader();
		imgLoader.load(new URLRequest(xmlData.thumb*));
		imgLoader.x=5;
		imgLoader.y=5;

		thumbHolder.thumbOver=thumbOver;
		thumbHolder.addChild(imgLoader);
		thumbHolder.addChild(thumbOver);
		thumbHolder.x = -285 + (thumbHolder.width + 5) * x_counter;
		thumbHolder.y = -385 + (thumbHolder.height + 5) * y_counter;

		if (x_counter<columns) {
			x_counter++;
		} else {
			x_counter=0;
			y_counter++;
		}


		addChild(thumbHolder);


		thumbHolder.xmlData=xmlData*;
		thumbHolder.buttonMode=true;
		thumbHolder.addEventListener(MouseEvent.ROLL_OVER, onOver,
		                                 false, 0, true);
		thumbHolder.addEventListener(MouseEvent.ROLL_OUT, onOut,
		                               false, 0, true);
		thumbHolder.addEventListener(MouseEvent.CLICK, onClick,
		                               false, 0, true);

	}
}

function onOver(e:Event):void {
	var obj:Object=e.currentTarget;
	var myTween:Tween=new Tween(obj.thumbOver,"alpha",Regular.easeIn,0.1,0.3,0.1,true);
}

function onOut(e:Event):void {
	var obj:Object=e.currentTarget;
	var myTween:Tween=new Tween(obj.thumbOver,"alpha",Regular.easeOut,0.3,0,0.3,true);
}

PLAYMc.x=-8;
PLAYMc.y=-87.5;


function onClick(e:Event):void {
	var obj:Object=e.currentTarget;

	PLAYMc.ex.addEventListener(MouseEvent.CLICK, Exit, false, 0, true);
///////////////////////////////////////////////////////////////////////////Next Button
	//PLAYMc.nxt.addEventListener(MouseEvent.CLICK, Nxt, false, 0, true);
///////////////////////////////////////////////////////////////////////////

	PLAYMc.holder.addChild(IMGLoader);
	IMGLoader.x=-288;
	IMGLoader.y=-165;
	IMGLoader.load(new URLRequest(obj.xmlData.path));

	PLAYMc.infoTxt.text=obj.xmlData.txt.text();
	PLAYMc.imgname.text=obj.xmlData.imgName.text();

}

function onComplete(e:Event):void {
	var obj:Object=e.currentTarget;
	addChild(PLAYMc);
	PLAYMc.visible=true;
	TransitionManager.start(PLAYMc,{type:Fade, direction:Transition.IN, duration:0.7,  easing:Strong.easeOut});

////////////////////////////////////////////////////////This is where i'm trying to get the loaded pic clickable

	if (obj.xmlData.Link!=null) {
		buttonMode=false;
	} else {
		buttonMode=true;
		addEventListener(MouseEvent.CLICK, view, false, 0, true);
	}
///////////////////////////////////////////////////////////////////////////
}

function Exit(e:MouseEvent) {
	var obj:Object=e.currentTarget;
	TransitionManager.start(PLAYMc,{type:Fade, direction:Transition.OUT, duration:0.3,  easing:Strong.easeIn});
	PLAYMc.holder.IMGLoader.unload(new URLRequest(obj.xmlData.path));
}

function view(e:MouseEvent) {
	var obj:Object=e.currentTarget;
	navigateToURL(new URLRequest(obj.xmlData.Link));
}

//////////////////////////////////////////////////////////This is were i'm trying to put the NEXT PIC function
/*function Nxt(e:Event) {
var obj:Object=e.currentTarget;
PLAYMc.holder.IMGLoader.load(new URLRequest(obj.xmlData.path++));
}*/
///////////////////////////////////////////////////////////////////////////

Xml Structure

<image>
	
          <path>./Output/images/Ps/vi002.jpg</path>
		
         <thumb>./Output/images/Ps/vi002_thumb.jpg</thumb>
		
         <txt> Info About the image </txt>

         <imgName> VI-002 </imgName>
		
</image>

<image>
	
          <path>./Output/images/Ps/vi002.jpg</path>
		
         <thumb>./Output/images/Ps/vi002_thumb.jpg</thumb>
		
         <txt> Info About the image </txt>

         <imgName> VI-002 </imgName>
		
</image>