I have an array of files and I want to download them all. What is the best way to do that, because I think that the code bellow will not work, because it doesn't wait until each download is finished.
var c = Titanium.Network.createHTTPClient(); for(var i=0;i<array.length;i++){ c.setTimeout(10000); c.onload = function(){ var f = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, filename); }; // open the client c.open('GET', url); // send the data c.send(); }I want to download one after the other because I have one Progressbar and I want to change the message for each file.