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. ( 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(; 
	xmlLength = (;
	currentWidth = ([currentIndex]);
	imagePath = ([currentIndex]);
	currentHeight = ([currentIndex]);
var loader:URLLoader = new URLLoader(); 
var url:URLRequest = new URLRequest(xmlPath); 
loader.addEventListener(Event.COMPLETE, onXMLLoad); 

function parse () :void {
	var photos:URLRequest = new URLRequest (imagePath);

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.