XML help

I have a function that loads and XML file. Which populates a scrollbar with images. I have three sections in my application Education, Hospital and Retail. The images being loaded differ in these 3 sections only by there placement. So for example, in education the image order is 1, 2, 3. For Hospital the image order needs to be 3,1,2 and of course Retail is say is 2,3,1. I might add that more then 20 images are being loaded and it is only the first 3 that need shuffled.

I want to use the same XML file for each section. Rather than duplicated the code 3 times and write 3 different XML files, can I move the images to the correct position say using a if statement like if(education == true); then image order = this; or if(hospital == true); then image order = this. Does that make sense? Is that even doable?

If it is how do I do that. Can some one show me?


//set up XML loader to load color list
var myXMLHC:XMLList;
var myLoaderHC:URLLoader = new URLLoader();
myLoaderHC.addEventListener(Event.COMPLETE, xmlLoadedHC, false, 0, true);
myLoaderHC.addEventListener(IOErrorEvent.IO_ERROR, onIOErrorHC, false,0,true);
myLoaderHC.load(new URLRequest("OptimaWallBase.xml"));

// Create the xmlLoaded function 
function xmlLoadedHC(event:Event):void {
    try {
        myXMLHC = XMLList(event.target.data);
        myLoaderHC.removeEventListener(Event.COMPLETE, xmlLoadedHC);
        myLoaderHC.removeEventListener(IOErrorEvent.IO_ERROR, onIOErrorHC);

        //Run the "for each" loop to iterate through all of 
        //the menu items listed in the external XML file
        for each (var pic:XML in myXMLHC..pic) {
            var picImageHC:String = pic.image.toString();
            var picloaderHC:Loader = new Loader();
            picloaderHC.load(new URLRequest(picImageHC));
            picloaderHC.x = HCxt;
            picloaderHC.y = HCyt+6.5;
            //add cell 
            mcHolderHC.addChild(picloaderHC);
            //
            picloaderHC.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoadedHC, false, 0, true);
            //set cityPic to the url of the picImage
            healthCareWallBasePic[picloaderHC] = picImageHC;
            //
            //set the spacing horizontal
            HCxt = HCxt+HCw+HCspace;
            //add mouseEvents for squares
            picloaderHC.addEventListener(MouseEvent.CLICK, getPicHC, false, 0, true);
            picloaderHC.addEventListener(MouseEvent.MOUSE_OVER, showHoverHC, false, 0, true);
            picloaderHC.addEventListener(MouseEvent.MOUSE_OUT, hideHoverHC, false, 0, true);
        }
    } catch (err:Error) {
        trace("Could not parse loaded content as XML:
" + err.message);
    }
}