• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Download multiple images with Adobe AIR app (as3)

Contributor ,
Feb 27, 2017 Feb 27, 2017

Copy link to clipboard

Copied

Hi,

I'm trying to make my code download multiples images without a dialog box for the user on the AIR app.

I've got an array containing 18 web links (like : "http://www.myWebsite.com/zootopia.jpg"). I'd like to download the 18 images and naming them image1, image2, image3...image18.

As my array is changing every week, the code needs to check if image1 already exists. If so, replace it.

Here's what I did so far :

var products:Array;

function saveImage (event:Event😞void { 

var stream:URLStream = new URLStream();

var image1:File = File.documentsDirectory.resolvePath("image1.jpg");

var fileStream:FileStream = new FileStream(); 

stream.load(new URLRequest("http://www.myWebsite.com/lalaland.jpg"));

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);      

  }

}

So my code is only downloading the specific link I gave him ("http://www.myWebsite.com/lalaland.jpg") and save it as "image1.jpg".

I'd like to download all the weblink of my "products" array.

How can I do ?

Also I'd like to name every files "image+number" (image1, image2).

Do you know how could I do that ?

Thank you for your help.

TOPICS
Development

Views

423

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines