dimanche 26 février 2017

Save multiple images with one function - AS3 ADOBE AIR

I've got an Array with 17 web links of images

        var products:Array;
        trace(products) 

 // Ouput : 
"http://ift.tt/2l0UErI"
"http://ift.tt/2ldVWLf"
"http://ift.tt/2l0QP5O"
    ..etc

If I do products[10].movieimage; the output will be the 9th link (something like : "http://ift.tt/2le3M7A")

I'm looking for downloading every images without a dialog box.

I manage to do so for 1 image with the specific link, like that :

function saveImage (event:Event):void {

 var stream:URLStream = new URLStream(); 
 var image1:File = File.documentsDirectory.resolvePath("test.jpg"); 
 var fileStream:FileStream = new FileStream(); 

stream.load(new URLRequest("http://ift.tt/2le3M7A")); 
stream.addEventListener(Event.COMPLETE, writeComplete); 
        

 function writeComplete(evt:Event):void  { 
                var fileData:ByteArray = new ByteArray(); 
                stream.readBytes(fileData,0,stream.bytesAvailable); 
                fileStream.openAsync(image1, FileMode.UPDATE); 
                fileStream.writeBytes(fileData,0,fileData.length); 
                fileStream.close(); 
                 trace("writeComplete");
                 trace(image1.url); 
        } 
}

Question : Is there a way to download all the images with the web links of my products array ?

If you could show me how, with a bit of code, I could that.

Also, note that I'd like to load the images then in Uiloader, like that :

    function loadImages():void {
uiloader1.source = image1.url;
uiloader2.source = image2.url;
etc...
    }

Aucun commentaire:

Enregistrer un commentaire