XML & why?

I’m pretty new to XML but I have a new project that i’d like to use it for so that I can structure a lot of basic data that just repeated…I have a my XML file set up with names and image paths:

 
<studentList>
    <student>
        <image>images/ken.jpg</image>
        <names>Ken Forumsrule</names>
    </student>
<!--and so on like that........-->
</studentList>

Then I have my AS set up all nice-like to read the doc and give me two arrays for the names and images:

var xmlDoc:XML = new XML();
System.useCodepage = true;
xmlDoc.ignoreWhite = true;
// Check for XML Doc
xmlDoc.onLoad = function(ok:Boolean) {
 if (ok) {
  doMenu(this);
 } else {
  trace("XML did not load");
 }
};
// load XML doc
xmlDoc.load("student_list.xml");
function doMenu(xmlNode:XML) {
 var total:Number = xmlNode.firstChild.childNodes.length;
 // Create Arrays for names & Image paths
 var aImages = new Array();
 var aNames = new Array();
 // Loop through XML doc and retrieve data for arrays
 for (var i = 0; i<total; i++) {
  //pics* = xmlNode.firstChild.childNodes*.attributes.image;
  aImages* = xmlNode.firstChild.childNodes*.childNodes[0].firstChild.nodeValue;
  aNames* = xmlNode.firstChild.childNodes*.childNodes[1].firstChild.nodeValue; 
 }
 trace(aImages);
 trace(aNames);
}
trace(aNames[1]);

Now my question is, the trace within the function work fine, but when I try to trace outside, it don’t work! WHY? Is there a trick to working with those arrays outside the function…

Thanks…Remember ~Newbie