Jump to content

AS3: Download Files using a For Each Loop


xProteuSx

Recommended Posts

Please keep in mind that I am a TOTAL NOOB. I am not asking anyone to code my entire project, but I am easily lost in many cases. Your help and patience is much appreciated ...


My AS3 code looks something like this:



var totalFeatureImageDownloads:Number = 0; //total file size of all feature images, in bytes
var totalFeatureImageDownloaded:Number = 0; //total downloaded of all feature images, in bytes

for each(var featureimage:XML in xml.featureimages.imgurl)
{
trace(featureimage);
var featureImageRequest:URLRequest = new URLRequest(featureimage);
var featureImageLoader:URLLoader = new URLLoader(featureImageRequest);
totalFeatureImageDownloads = totalFeatureImageDownloads + featureImageLoader.bytesTotal;
trace(featureImageLoader.bytesTotal);
}

Currently I have 3 images in the XML file, and their URL's are traced properly. However, bytesTotal always equals 0. Also, I know that this loop creates 3 identically named URLRequest's and 3 identically named URLLoaders. I probably need to create 3 differently named ones.


I would like all the images to be downloaded simultaneously, and I need to calculate the combined file size for all three, along with the download status as a fraction (bytesLoaded / bytesTotal).


I have multiple scenarios like this, and am stuck until I get this finished. Your help is much appreciated. Cheers.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.