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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.