F8 AS xml event handler problem

I’m working with AS 2.0.
Well I have the xml load in my constructor so I know I make the call to load the xml before I call the getTeam function but I’ve read that the xml won’t necessarily load right away or something like that. I’ve put an if statement that takes the success parameter from the xml.onLoad function so I thought that guarenteed that all the data would load before moving on to other functions but maybe that isn’t the case. Is there anyway to make sure that the xml has loaded completely before anything else is done? When I trace the teams array inside the event handler it outputs the Objects in the array but when I try tracing the teams array anywhere else but in the event handler it gives me undefined.
Here’s the code for my class and the test code follows it:


class League{
 private static var numberOfTeams:Number=32;
 private var teams:Array;
 private var games:Array;
 private var numberOfGamesPlayed:Number;
 
 public function League()
 {
  teams=new Array();
  games=new Array();
  var parent=this;
  var xmlInput:XML=new XML();
  xmlInput.ignoreWhite=true;
  xmlInput.onLoad=function(success)
  {
   if(success)
   {
    for(var i=0; i<xmlInput.firstChild.childNodes.length; i++)
       {
     var t:Team=new Team(xmlInput.firstChild.childNodes*.attributes.name,
                      xmlInput.firstChild.childNodes*.attributes.totalGames,
             xmlInput.firstChild.childNodes*.attributes.wins,
             xmlInput.firstChild.childNodes*.attributes.losses,
             xmlInput.firstChild.childNodes*.attributes.pointsForPerGame,
             xmlInput.firstChild.childNodes*.attributes.yardsForPerGame,
             xmlInput.firstChild.childNodes*.attributes.thirdDownPercentage,
             xmlInput.firstChild.childNodes*.attributes.penaltyYards,
             xmlInput.firstChild.childNodes*.attributes.pointsAllowedPerGame,
             xmlInput.firstChild.childNodes*.attributes.yardsAllowedPerGame,
             xmlInput.firstChild.childNodes*.attributes.interceptions,
             xmlInput.firstChild.childNodes*.attributes.forcedFumbles,
             xmlInput.firstChild.childNodes*.attributes.puntReturnAvg,
             xmlInput.firstChild.childNodes*.attributes.kickReturnAvg);
    
       parent.teams.push(t);
      }
   }
  }
  xmlInput.load("NFLTeamStats.xml");
  
  var xmlInput2:XML=new XML();
  xmlInput2.ignoreWhite=true;
  xmlInput2.onLoad=function(success)
  {
   if(success)
   {
    for(var j=0; j<xmlInput2.firstChild.childNodes.length;j++)
       {
        for(var k=0; k<xmlInput2.firstChild.childNodes[j].childNodes.length; k++)
        {
         var g:Game=new Game(xmlInput2.firstChild.childNodes[j].attributes.id,
              xmlInput2.firstChild.childNodes[j].childNodes[k].attributes.id,
              xmlInput2.firstChild.childNodes[j].childNodes[k].attributes.winner,
              xmlInput2.firstChild.childNodes[j].childNodes[k].attributes.loser,
              xmlInput2.firstChild.childNodes[j].childNodes[k].attributes.margin,
              xmlInput2.firstChild.childNodes[j].childNodes[k].attributes.total);
     
         games.push(g);
        }
          }
   }
  }
  xmlInput2.load("NFLGames.xml");
 }
 
 public function getGamesPlayed()
 {
  numberOfGamesPlayed=0;
  var xmlInput3:XML=new XML();
  xmlInput3.ignoreWhite=true;
  xmlInput3.load("NFLGames.xml");
  trace(xmlInput3.firstChild.childNodes[0].attributes.id);
  xmlInput3.onLoad=function()
  {
      for(var i=0; i<xmlInput3.firstChild.childNodes.length; i++)
      {
       trace("outer loop");
       for(var j=0; j<xmlInput3.firstChild.childNodes*.childNodes.length; j++)
       {
        trace("inner loop");
           numberOfGamesPlayed++;
        trace(numberOfGamesPlayed);
       }
         }
     }
  return numberOfGamesPlayed;
 }
 
 public function getTeams():Array
 {
  trace(teams.length);
  var teamsArray:Array=new Array();
  teamsArray=teams.slice();
  trace(teamsArray.length);
  return teamsArray;
 }
 
 public function getGames():Array
 {
  var gamesArray:Array=new Array();
  gamesArray=games.slice();
  return gamesArray;
 }
}


var l:League=new League();
trace(l.getTeams());