[flexcoders] Re: how to update a progress bar when uploading an image

2009-11-17 Thread jamesfin

There isn't a way to do this.  You can simulate a progress bar but for whatever 
reason, this functionality doesn't exist.  If you have a look at speedtest.net, 
they show download progress nicely but their upload progress is simulated.

I've thought about making another (different) request to the server to get the 
number of bytes transferred, but that's a nasty hack.  It also depends on how 
big your files that are being uploaded.  If they are all fairly large then that 
might work for you.

Perhaps someone can explain the limitations within the browser framework to 
help us understand why we can't get upload status.  Alternatively, if you are 
ambitious, go get the Firefox source Firefox and figure it out for yourself.

Anyone else have a different opinion/solution?



--- In flexcoders@yahoogroups.com, stinasius stinas...@... wrote:

 hi, am trying to upload and image and i would like to show progress while 
 uploading process goes on by updating the progress bar but the progress bar 
 seems not to get updated. here is my code
 
 formitem component
 ?xml version=1.0 encoding=utf-8?
 mx:FormItem xmlns:mx=http://www.adobe.com/2006/mxml; 
 creationComplete=init()
   
   mx:Script
   ![CDATA[
   import mx.managers.PopUpManager;
   import components.progress_popup;
   
   private var fileRef:FileReference;
   private var progress_win:progress_popup;
   
   private function init():void{
   fileRef = new FileReference();
   fileRef.addEventListener(Event.SELECT, fileRef_select);
   fileRef.addEventListener(ProgressEvent.PROGRESS, 
 progressHandler);
   fileRef.addEventListener(Event.COMPLETE, 
 fileRef_complete);
   }
   
   private function browseAndUpload():void{
   fileRef.browse();
   message.text = ;
   }
 
   private function fileRef_select(event:Event):void{
   var request:URLRequest = new 
 URLRequest(cfcs/upload.cfm)
   try 
   {
   fileRef.upload(request);
   } 
   catch (err:Error)
   {
   message.text = ERROR: zero-byte file;
   }   
   memPhoto.text = event.currentTarget.name;
   createdprogressPopup();
   progress_win.uploadProgress.setProgress(0, 100);
   progress_win.uploadProgress.label = Loading 0%;
   }
   
   private function fileRef_complete(event:Event):void{
   message.text +=  (complete);
   removeMe();
   }
   
   private function createdprogressPopup():void{
   
 progress_win=progress_popup(PopUpManager.createPopUp(this,progress_popup,true));
   }
   
   private function removeMe():void {
   PopUpManager.removePopUp(progress_win);
   }
   
   private function progressHandler(event:ProgressEvent):void{
   //var file:FileReference = FileReference(event.target);
   
 progress_win.uploadProgress.setProgress(event.bytesLoaded, event.bytesTotal); 
   
   }
   
   ]]
   /mx:Script
   
   mx:HBox width=240
   mx:TextInput width=155 id=memPhoto enabled=false/
   mx:Button label=Browse click=browseAndUpload();/  
 
   /mx:HBox
   mx:Label id=message/
 /mx:FormItem
 
 popup with progress bar to show progress
 
 ?xml version=1.0 encoding=utf-8?
 mx:TitleWindow xmlns:mx=http://www.adobe.com/2006/mxml; layout=vertical 
 creationCompleteEffect={customMove} removedEffect={customHide} 
 title=Uploading Image
   mx:Script
   ![CDATA[
   import mx.managers.PopUpManager;
   import mx.effects.easing.*;
   ]]
   /mx:Script
 
   
   mx:Parallel id=customMove target={this}
 mx:Move yFrom=0 xFrom={(stage.width  - this.width) / 2} 
 xTo={(stage.width  - this.width) / 2} yTo={(stage.height - this.height) / 
 2} easingFunction=Elastic.easeOut duration=500 /
   mx:Fade duration=500 /
 /mx:Parallel
 
 mx:Parallel id=customHide target={this}
 mx:Move yFrom={(stage.height - this.height) / 2} 
 xFrom={(stage.width  - this.width) / 2} xTo={(stage.width  - this.width) / 
 2} yTo={stage.height} duration=500 /
   mx:Fade alphaFrom=1 alphaTo=0 duration=500 /
 

[flexcoders] Re: how to update a progress bar when uploading an image

2009-11-17 Thread stinasius
wow... so the only way is to use the indeterminate to show that smething is 
happening. thanks but in case someone has a solution please share. thanks again 



[flexcoders] Re: how to update a progress bar when uploading an image

2009-11-17 Thread jamesfin

This also assumes you are trying to upload text vs. binary depending on how 
your server is configured.

This is an example that you might be able to leverage if you have binary.

http://www.adobe.com/devnet/flex/articles/file_upload_05.html


--- In flexcoders@yahoogroups.com, stinasius stinas...@... wrote:

 wow... so the only way is to use the indeterminate to show that smething is 
 happening. thanks but in case someone has a solution please share. thanks 
 again