codice:
function searchKey() {
var myDay = parseInt( myFile.substr(0, 2) ) + 1;
var myMonth = parseInt( myFile.substr(2, 2) );
var myYear = parseInt( myFile.substr(4, 4) );
if( myDay > 31 ) {
myDay = 1;
myMonth++;
}
if( myMonth > 12 ) {
myMonth = 1;
myYear += 1;
}
myFile = myDay < 10 ? "0" + myDay : myDay;
myFile += myMonth < 10 ? "0" + myMonth : myMonth;
myFile += myYear;
return myFile;
}
function searchFile( myFile ) {
var dati = new LoadVars();
dati.onLoad = function(success) {
if( this.loaded ){
trace("trovato il file " + myFile);
// fai quello che devi fare ...
}
else {
searchFile( searchKey() );
}
}
dati.load( myFile + ".txt" );
}
var myDate = new Date();
var myFile = myDate.getDate() < 10 ? "0" + myDate.getDate() : myDate.getDate();
myFile += (myDate.getMonth()+1) < 10 ? "0" + (myDate.getMonth()+1) : (myDate.getMonth()+1);
myFile += myDate.getFullYear();
searchFile( myFile );