Action Script 3.0 insert a delay
i'm new to AS and i'm trying to manage with some issue.

i'm having the next script

    var t:Date = new Date ();
    var day=t.getDate();
    var month=t.getMonth()+1;
    var today=day+"."+month;
    var u:Number = 0;
    
    var b_persons:Array = new Array ();
    
    var loader:URLLoader = new URLLoader(new URLRequest("bday.xml"));
    var bday_file:XML = new XML();
    
    loader.addEventListener(Event.COMPLETE, endLoad);
    
    
    function endLoad(all_data:Event)
    
    {
       bday_file = XML(all_data.target.data);
    
       for each (var person:XML in bday_file.Person) 
       {
    	  if (person.BD == today) 
    	  {
    		  b_persons.push(person.FIO);
    		  
    		  trace (b_persons.length);
    	  }
       }
    }
    
    function assign_txtBdayPerson()
    {
    	txtBdayPerson.text=b_persons[u];
    	trace(b_persons[u]);
    	u=u+1;
    	if (u >= b_persons.length)
    	{clearInterval(delay_assign_txtBdayPerson);}
    	
    }
    
    trace ("Test"+b_persons.length);
    
    if (b_persons.length != 0)
    	{
    		var delay_assign_txtBdayPerson = setInterval(assign_txtBdayPerson,3000);
    	}

my xml file has 2 suitable conditions, and the output window shows me the next sequence 

Test 0  than    1 and last  2

so it seems that  trace ("Test"+b_persons.length); runs earlier than  function endLoad(all_data:Event) is completed

could you please help me?

 
 


Action Script 3.0 insert a delay
===

i'm new to AS and i'm trying to manage with some issue.

i'm having the next script

    var t:Date = new Date ();
    var day=t.getDate();
    var month=t.getMonth()+1;
    var today=day+"."+month;
    var u:Number = 0;
    
    var b_persons:Array = new Array ();
    
    var loader:URLLoader = new URLLoader(new URLRequest("bday.xml"));
    var bday_file:XML = new XML();
    
    loader.addEventListener(Event.COMPLETE, endLoad);
    
    
    function endLoad(all_data:Event)
    
    {
       bday_file = XML(all_data.target.data);
    
       for each (var person:XML in bday_file.Person) 
       {
    	  if (person.BD == today) 
    	  {
    		  b_persons.push(person.FIO);
    		  
    		  trace (b_persons.length);
    	  }
       }
    }
    
    function assign_txtBdayPerson()
    {
    	txtBdayPerson.text=b_persons[u];
    	trace(b_persons[u]);
    	u=u+1;
    	if (u >= b_persons.length)
    	{clearInterval(delay_assign_txtBdayPerson);}
    	
    }
    
    trace ("Test"+b_persons.length);
    
    if (b_persons.length != 0)
    	{
    		var delay_assign_txtBdayPerson = setInterval(assign_txtBdayPerson,3000);
    	}

my xml file has 2 suitable conditions, and the output window shows me the next sequence 

Test 0  than    1 and last  2

so it seems that  trace ("Test"+b_persons.length); runs earlier than  function endLoad(all_data:Event) is completed

could you please help me?

 
 

