Adobe AIR Downloader app
Since designing and estimating the work on this downloader app, the time has come to actually build the thing.
The first thing to overcome was using the built-in components to facilitate a download. Searching for assistance on this was made particularly tricky given that my previous article seemed to keep appearing in Google despite providing no actual help.
Huge thanks go out to Elad and his flex download api. This helped me get going enormously. To start with it only supported single downloads, and although I could queue these up, I wanted to be able to support concurrent downloads.
To do this I extended the progressEvent class to be able to attach the unique ID of the file being downloaded. This enables me to uniquely identify the progress bar for each download as I go through.
package
{
import flash.events.Event;
import flash.events.ProgressEvent;public class MultipleProgressEvent extends ProgressEvent
{
public var fileID:String;public function MultipleProgressEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false)
{
super(type, bubbles, cancelable);
}
}
}
…I also changed the DownloadManager class to include the fileID within the method as follows…
private var fileIDString:String = “”;
public function getFileID():String
{
return fileIDString;
}public function DownloadManager(fileID:String)
{
super();
fileIDString = fileID;
}
Next I ditched the hard-coded progress bar tag and dyamically generated the progress bar tag, along with the other graphical elements at the point of parsing the XML containing the download URL and meta information.
Here is my call to my XML service…
url=”http://www.imbimp.com/someXML.xml”
result=”resultHandler(event)”
fault=”faultHandler(event)”/>
… and here is the dynamic generation of the progress bar…
private function resultHandler(event:ResultEvent):void
{
loadedData = event.result.myDownloadResponse.content.pendingDeliveries.delivery as ArrayCollection;
for(var count:int = 0; count < loadedData.length; count++)
{
var fileID:String = loadedData.getItemAt(count).product.proprietaryId;myProgressBar = new ProgressBar();
myProgressBar.name = fileID;
myProgressBar.minimum = 0;
myProgressBar.x = 0;
myProgressBar.y = 30;
myProgressBar.label = “Progress 0%”;
myProgressBar.mode = “manual”;progressBarContainer.addChild (myProgressBar);
}
}
All that remained was to modify the onDownloadProgress function to target the progress bar using the fileID. This was actually the most difficult bit, since I had not realised that when using Flex you cannot access the properties of an object while it is a DisplayObject, and that you must specify the object type before changing properties. Not quite sure where this is documented…I ended up getting the support from an experienced Flex developer to find the answer.
Something like this…
(ProgressBar)(progressBarContainer.getChildByName(event.fileID)).minimum = value;
Now this is working more or less, I need to investigate how I can integrate with other services and actually launch the app in the first place. The integration here will be critical to ensure the security and end to end goodness.

Self Portrait Collage
Release Animals
100 Mile Journey
Boni from Trap Door Costume
Monster Cake!
Sinclair ZX Spectrum +2 Costume
Video Project for Rimmer’s Wedding
Vodafone Micro SIM iPhone 4 Confusion
Integrating AIR Application with iTunes
Custom Flex WordPress Frontend




Comments/Trackbacks