Ho questo script che dovrebbe verificare se una serie di txt esiste o no e fare qualcosa di conseguenza.

k=0;

do {
//carico il file .txt
fileExists=new LoadVars();
//fileExits._parent=this;
fileExists.load(k+".txt")
//verifico se il file è stato caricato success rende true o false
fileExists.onLoad=function(success){
if(success){
trace (k);
}
else {
trace ("pippo")
}
}
k++;
}
while (k<31);

tutto ciò perchè secondo l'esistenza o meno di + files devo fare qualcosa.
Quando il file viene trovato nell'output viene visualizzata la var k altrimenti il mitico pippo.

A questo punto vi mostro l'output del debugger:
pippo
Error opening URL "0.txt"
pippo
Error opening URL "1.txt"
pippo
Error opening URL "2.txt"
pippo
Error opening URL "3.txt"
pippo
Error opening URL "4.txt"
pippo
Error opening URL "5.txt"
pippo
Error opening URL "6.txt"
pippo
Error opening URL "7.txt"
pippo
Error opening URL "8.txt"
pippo
Error opening URL "9.txt"
pippo
Error opening URL "10.txt"
pippo
Error opening URL "11.txt"
pippo
Error opening URL "12.txt"
pippo
Error opening URL "13.txt"
pippo
Error opening URL "14.txt"
31
pippo
Error opening URL "16.txt"
pippo
Error opening URL "17.txt"
pippo
Error opening URL "18.txt"
pippo
Error opening URL "19.txt"
pippo
Error opening URL "20.txt"
pippo
Error opening URL "21.txt"
pippo
Error opening URL "22.txt"
pippo
Error opening URL "23.txt"
pippo
Error opening URL "24.txt"
pippo
Error opening URL "25.txt"
pippo
Error opening URL "26.txt"
pippo
Error opening URL "27.txt"
31
31
31

dove quello che non capisco è questo: perchè se il valore di k è corretto e viene caricato il file corrispondente il trace mostra 31 invece di 15, 28, 29 e 30?

Gierre