How can I substitute xml file with another in AS3

Hi, I’m fairly new at AS3 and I’m having a though time trying to replace an xml with another. I have five buttons that link to different picture galleries. All of them work with different xml files. The first xml file is called from an external as file. (CenteredSlideShow.as). I can load five different xml files by using modified versions of this code but it ends up being a whole lot of code on my .fla. and the other pictures remain loaded.


var xmlPath = "ilustrationsAS3.xml";
var imagePath="CrouchingCity.jpg";

function onXMLLoad(event:Event):void { 
    var xml:XML = new XML(event.target.data); 
    xmlCatch=xml;
	xmlLength = (xml.pictures.picture.length());
	currentWidth = (xml.pictures.picWidth[currentIndex]);
	imagePath = (xml.pictures.picture[currentIndex]);
	currentHeight = (xml.pictures.picHeight[currentIndex]);
	parse();
} 
var loader:URLLoader = new URLLoader(); 
var url:URLRequest = new URLRequest(xmlPath); 
loader.addEventListener(Event.COMPLETE, onXMLLoad); 
loader.load(url);

function parse () :void {
	var photos:URLRequest = new URLRequest (imagePath);
		photoLoader.load(photos);
		picAlign();
		addChild(photoLoader);
}

I had figured this out for AS2 but loading xml files in AS3 is completely different. Is there any way to make this code reusable, so as to not have it five times along with about a zillion vars? I would really apreciate any help.