Help with a dynamic xml menu

Hey guys, I am having a bit of a problem with my XML generated menu and was wondering if anyone could offer me some guidance here.


pages.stop();
xStart = 5;
yStart = 48;
bWidth = 82;
bHeight = 20;
var menuXml = new XML();
loadXml("flash/xml/menu.xml");
function loadXml(file:String) {
 menuXml.ignoreWhite = true;
 menuXml.onLoad = loadMapData;
 menuXml.load(file);
 function loadMapData() {
  for (var i = 0; i<this.firstChild.childNodes.length; i++) {
   var bn = this.firstChild.childNodes*.attributes.buttonName;
   var fn = this.firstChild.childNodes*.attributes.fileName;
   var b = _root.attachMovie("button", bn, i);
   b._x = xStart
   b._y = yStart+(bHeight*i);
   b.txt = bn;
   b.onPress = function() {
    pages.gotoAndStop(this.txt);
    pages.heading = this.txt;
    target = this._y;
**    pages.loadMovie(fn); 
    pages.play();**
   };
  }
 }
}

Bit of explanation, this calls up the menu.xml file which contains tags with two attributes, one is called buttonName (for example “Lorum Ipsum”), the other is called fileName (for example “lorumipsum.swf”).

It goes into a for loop which pulls out all the child nodes and then places them on screen within instances of a movie clip (button).

The buttons all load up fine with the appropriate text but the problem I am having is that when you click on the button to load up an external .swf file no matter what you click the value is always the last one loaded in from the xml file.

I suspect its because of the for loop and just requires an additional line or two of code but I am stumped.

Any help would be greatly appreciated!