Xml and sequential movie clips

Hello -
I am processing a string of xml data and populating variables (using the same variables, but changing their values with each value of i) using a for statement. Within the for statement I call the function attachMessage(i); which launches a function that attaches an instance of a movieclip from the library and displays it on the stage. the library movieclip contains dynamic text fields that populate with the value of the variables populated from the XML that was processed. Each time the library movieclip is added to the stage, the dynamic text fields should be populated with the variable values generated for that instance of i.

The problem is that the library movieclip instance is put on the stage for each value of i in the for statement, but the dynamic text is being populated with the information from the last set of variable values, so my library movie clip has multiple instances on the stage (one for each unique value of i), but the dynamic text fields are populated with the same thing–the information that matches the last set of variable values from the XML that was processed.

hope this isn’t tremendously confusing… here’s some of the code:

Code from Scene 1:

function attachMessage(n:Number):Void{
 var MessageX:String = "Message" + n;
 trace("this is Messagex");
 trace (MessageX);
 this.attachMovie("mcMessageHolder", MessageX, this.getNextHighestDepth());
 if (MessageX != "Message0"){
  var PrevMessage:String = "Message" + (n-1);
  trace("this is PrevMessage");  
  trace(PrevMessage);
  this[MessageX]._x = 7;
  this[MessageX]._y = (79 + (n * 85));
 }
 else{
  Message0._x = 7;
  Message0._y = 79;
 }
}
//Begin XML//
var xmlmsgInfo:XML = new XML();
xmlmsgInfo.ignoreWhite=true;
xmlmsgInfo.onLoad = function(bSuccess:Boolean):Void {
 if(bSuccess){
  trace("xmlmsgInfo.onLoad(bSuccess)");
  var xnRoot:XMLNode = this.firstChild;
  var xnMessage:XMLNode;
  var xnTitle:XMLNode;
  var xnSpeaker:XMLNode;
  var xnSeries:XMLNode;
  var xnDate:XMLNode;
  var xnDescr:XMLNode;
  var xnBook:XMLNode;
  var xnChapter:XMLNode;
  var xnVerse:XMLNode;
  var xnPDF:XMLNode;
  var xnAudio:XMLNode;
  var xnVideo:XMLNode;
  var xnNotes:XMLNode;
  var xnMinName:XMLNode;
  for(var i:Number = 0; i < xnRoot.childNodes.length; i++){
   xnMessage = xnRoot.childNodes*;
   xaMessageID = xnMessage.attributes.ID;
   trace(xaMessageID);
   xnTitle = xnMessage.firstChild;
   xaTitleV = xnTitle.attributes.V;
   trace(xaTitleV);
   xnSpeaker = xnTitle.nextSibling;
   xaSpeakerIDV = xnSpeaker.attributes.V;
   trace(xaSpeakerIDV);
   xnSeries = xnSpeaker.nextSibling;
   xaSeriesV = xnSeries.attributes.V;
   trace(xaSeriesV);
   xnDate = xnSeries.nextSibling;
   xaDateV = xnDate.attributes.V;
   trace(xaDateV);
   xnDescr = xnDate.nextSibling;
   xaDescrV = xnDescr.attributes.V;
   trace(xaDescrV);
   xnBook = xnDescr.nextSibling;
   xaBookV = xnBook.attributes.V;
   trace(xaBookV);
   xnChapter = xnBook.nextSibling;
   xaChapterV = xnChapter.attributes.V;
   trace(xaChapterV);
   xnVerse = xnChapter.nextSibling;
   xaVerseV = xnVerse.attributes.V;
   trace(xaVerseV);
   xnPDF = xnVerse.nextSibling;
   xaPDFV = xnPDF.attributes.V;
   trace(xaPDFV);
   xnAudio = xnPDF.nextSibling;
   xaAudioV = xnAudio.attributes.V;
   trace(xaAudioV);
   xnVideo = xnAudio.nextSibling;
   xaVideoV = xnVideo.attributes.V;
   trace(xaVideoV);
   xnNotes = xnVideo.nextSibling.firstChild;
   trace(xnNotes);
   xnMinName = xnMessage.lastChild;
   xaMinNameV = xnMinName.attributes.V;
   trace(xaMinNameV);
   _level0.Message = xaMessageID;
   _level0.Title = xaTitleV;
   _level0.Speaker = xaSpeakerIDV;
   _level0.Series = xaSeriesV;
   _level0.DateOf = xaDateV;
   _level0.Descr = xaDescrV;
   _level0.Book = xaBookV;    
   _level0.Chapter = xaChapterV;
   _level0.Verse = xaVerseV;
   _level0.PDF = xaPDFV;
   _level0.AudioPath = xaAudioV;
   _level0.VideoPath = xaVideoV;
   _level0.Notes = xnNotes;
   _level0.MinName = xaMinNameV;
   if(_level0.Verse == null){
     if(_level0.Chapter == null){
      if(_level0.Book == null){
       _level0.Scrptref = "no reference available";
      }
      else{
       _level0.Scrptref = _level0.Book;
      }
     }
     else{
      _level0.Scrptref = (_level0.Book + " " + _level0.Chapter);
     }
   }
   else{
    _level0.Scrptref = (_level0.Book + " " + _level0.Chapter + ":" + _level0.Verse);
   }  
   trace(_level0.Scrptref);
   attachMessage(i);
  }
 }
 else{
  trace("no records match");
 }
}

Code from mcMessageHolder movieClip in the Library:

var msgTitle:String = _level0.Title;
var msgSeries:String = _level0.Series;
var msgSpeaker:String = _level0.Speaker;
var msgDateOf:String = _level0.DateOf;
var msgDescr:String = _level0.Descr;
var msgScrptref:String = _level0.Scrptref;
var msgPDF:String = _level0.PDF;
var msgaudioPath:String = _level0.AudioPath;
var msgvideoPath:String = _level0.VideoPath;
var msgSpkrNotes:String = _level0.Notes;
function getDetails():Void{
 if(_level0.VideoPath != null){
  this.attachMovie("getvideo", "getVideo", this.getNextHighestDepth());
  getVideo._x = 315;
  getVideo._y = 29;
  getvideo.onRelease = function(){
   _root.attachMovie(MediaShell, mediaShell, _root.getNextHighestDepth());
   mediaShell._x = 7;
   mediaShell._y = 240;
   mediaShell._width = 484;
   mediaShell._height = 260;
   _level0.MediaType = "Video";
  }
 }
 else{
 }
 this.attachMovie("getaudio", "getAudio", this.getNextHighestDepth());
 getAudio._x = 380;
 getAudio._y = 29;
 getAudio.onRelease = function(){
  _root.attachMovie(MediaShell, mediaShell, _root.getNextHighestDepth());
  mediaShell._x = 7;
  mediaShell._y = 240;
  mediaShell._width = 484;
  mediaShell._height = 260;
  _level0.MediaType = "Audio";
 }
 this.msgtitle.text = msgTitle;
 this.series.text = msgSeries;
 this.scrptref.text = msgScrptref;
 this.date.text = msgDateOf;
 this.speaker.text = msgSpeaker;
}
getDetails();