Adobe Dreamweaver Forums



Last 10 THreads :         problems linking PDFs (Last Post : Alan - Replies : 3 - Views : 4 )           »          Flash movie not working in html (Last Post : WEBDavid - Replies : 0 - Views : 1 )           »          load xml into mc symbols (Last Post : DigitalUprising - Replies : 0 - Views : 1 )           »          drop down menu over flash (Last Post : ltartisel - Replies : 2 - Views : 3 )           »          Flash-PHP Mail Form (Last Post : kglad - Replies : 3 - Views : 4 )           »          Flash Controls Not Displaying in Embedded File (Last Post : kglad - Replies : 5 - Views : 6 )           »          DW Flash Encoder (Last Post : wycn - Replies : 2 - Views : 3 )           »          navigation bar (Last Post : G. Rex - Replies : 5 - Views : 6 )           »          Adobe Flash 10 kills Wimpy (Last Post : ClubEXL.com - Replies : 82 - Views : 955 )           »          static sound (Last Post : 21n9 - Replies : 10 - Views : 11 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Other Macromedia/Adobe Products > Flex
 
Tags:



Reply
  #1 (permalink)  
Old 12-01-2008, 01:03 PM
Mattg2379
 
Posts: n/a
Diggs:
Default File download issue

Good morning all.
I'm having trouble with a file download component I've written. It worked fine
debugging, but when testing an installed version of the application, there
seems to be a problem with the loop, and files not completely downloading.

I have tested, and one file in the loop is writing to the directory
(event.complete action) at about 45%.
How can I check if the total bytes downloaded is the same as total available,
and if not, force it to carry on the download for that particular item?

The code for the page is below:

public function Update():void {
if(appModel.fileArrCol.length > 0) {
var urlReq:URLRequest = new
URLRequest(appModel.fileArrCol[0][1].toString());
trace(urlReq.url);
urlStream = new URLStream();
urlStream.addEventListener(IOErrorEvent.IO_ERROR, onStreamError);
urlStream.addEventListener(ProgressEvent.PROGRESS, progressHandler);
urlStream.addEventListener(Event.COMPLETE, fileTransferHandler);
urlStream.load(urlReq);
}

}

private function fileTransferHandler(event:Event):void {
urlStream.readBytes(fileData, 0, urlStream.bytesAvailable);
var fileLoc:String = appModel.fileArrCol[0][2].toString() +
appModel.fileArrCol[0][0].toString();
var file:File = File.applicationStorageDirectory.resolvePath(fileL oc);
var fileStream:FileStream = new FileStream();
fileStream.addEventListener(Event.CLOSE, fileClosed);
fileStream.addEventListener(IOErrorEvent.IO_ERROR, onStreamError);
fileStream.openAsync(file, FileMode.WRITE);
fileStream.writeBytes(fileData, 0, fileData.length);
fileStream.close();
trace("File " + appModel.fileArrCol.length + ": " +
appModel.fileArrCol[0][0].toString());
}

private function onStreamError(event:IOErrorEvent):void{
//Alert.show("Invalid Username or Password!","Warning");
this.showCloseButton =true;
btnUpdate.visible = true;
trace(event.text);
}


private function progressHandler(event:ProgressEvent):void {
/* bar.setProgress( Number(event.bytesLoaded / event.bytesTotal), 1 );
*/
bar.setProgress(event.bytesLoaded,event.bytesTotal );
progLabel.text = "Downloading " + Math.round(event.bytesLoaded / 1024)
+ " kb of " + Math.round(event.bytesTotal / 1024) + " kb " +
(appModel.fileArr.length - 1) + " files remaining";
}


private function fileClosed(event:Event):void {
// run a progress bar or sqlite table update here
appModel.fileArrCol.removeItemAt(0);

if (appModel.fileArrCol.length > 0){
Update();
} else {
progLabel.text = "Uploads Complete";

var thisServerVersion:String = appModel.fileDownloadServerVersion;
var thisDescription:String = appModel.fileDownloadDescription;
var thisDownloadDate:String = appModel.fileDownloadDate;

// store the file download details within the database table
if(appModel.checkFileDownloadHistory(thisServerVer sion).valueOf() > 0) {
// a record matches the version number in the xml. do nothing
} else {

appModel.storeFileDownloadHistory(thisServerVersio n,thisDescription,thisDow
nloadDate);
}
// close the box down
PopUpManager.removePopUp(this)
}
}

public function init():void{
btnUpdate.visible = false;
this.showCloseButton = true;

if (appModel.urlAvailable){
Update();
}else{
Alert.show("No Network Connection Detected","Message");
this.showCloseButton =true;
btnUpdate.visible = true;
}
}


public function titleWindow_close(evt:CloseEvent):void {
PopUpManager.removePopUp(this)
}

The application reads the number of files from an xml file on the server. That
works fine, but I think the loop is wrong. In debug, it traces the file names
without a problem

Please please please can someone help me? I need to get this sorted and
resolved by this lunchtime.

Many thanks in advance,

Matt




Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 12:40 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Cheap Car Insurance - Compare Motor Insurance
Endsleigh Car Insurance Natwest Car Insurance
More Than Car Insurance Norwich Union Car Insurance
Prudential Car Insurance Zurich Car Insurance
Inactive Reminders By Mished.co.uk