hello I try to download multiple images in a row. I'm stuck for several days and could not find the solution. Currently I have this, but only the last image is recorded.
for (var j = 1; j <= nb_exercices; j++) { loadingLabel.text = 'Téléchargement de l\'exercice ' + j + ' / ' + nb_exercices;
var id = jsonObject.packExercices[j].id;
var f = id;
var xhr3 = Titanium.Network.createHTTPClient({
onload: function() {
var source = id + '.png';
f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,source);
f.write(this.responseData); // write to the file
Ti.App.fireEvent('image_downloaded', {filepath:f.nativePath});
}
});
var lien = 'http://myURL/' + id + '.png';
xhr3.open('GET',lien);
xhr3.send();
if (j >= nb_exercices)
{
actInd.hide();
loadingLabel.text = 'Téléchargement terminé';
}
}
Can you help me please ?