setInterval in a for loop - what am I doing wrong?

What I’m trying to achieve is that I’m planning to fetch data from an XML file in certain time sequences. For this I would need a simple function that has a growing variable. I tried to test this as a text field that would show my variable go from 0 to 2 with one second between each change - but I can’t get it to work. Could someone help me out?


for(var i=0; i<3; i++){
 timer = setInterval(countDown, 1000); 
 
 function countDown(){ 
  changing_number.text = i;
  trace(i);
  clearInterval(timer);
     }
}
 

Thanks in advance!