Delegate class problem

I’m using the delegate class to allow my class variables to be referenced inside an xml.onLoad event. More specifically I’m calling a push on an array(which is a member of my class) in the onLoad event function. When I trace the array’s length inside the event handler, it does indeed increase incrementally for each object pushed but when I try to trace outside the onLoad event handler it always outputs 0 as if I added nothing. Does anybody know why? I know I use the delegate class to fix the scope problem of the member array in the xml event but do I need to do something else to get the scope of the array back to the class? Or is something else going on?

Here’s the relevant code:


import mx.utils.Delegate;
class League{
private var teams:Array;
private var xmlInput:XML;
public function getTeams():Array
{
 var teamsArray:Array=new Array();
 teamsArray=teams.slice();
 return teamsArray;
}
private function loadTeams():Void
{
 teams=new Array();
 xmlInput=new XML();
 xmlInput.ignoreWhite=true;
 xmlInput.onLoad=Delegate.create(this, onTeamLoadEvent);
 xmlInput.load("NFLTeamStats.xml");
}
private function onTeamLoadEvent(success:Boolean):Void
{
 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);
    
    teams.push(t);
  }
 }
}
}

I call the the loadTeams function in the constructor for this class.