View comments | RSS feed

onProgress (FileReference.onProgress event listener)

onProgress = function(fileRef:FileReference, bytesLoaded:Number, bytesTotal:Number) {}

Invoked periodically during the file upload or download operation. The onProgress listener is invoked while the Flash Player transmits bytes to a server, and it is periodically invoked during the transmission, even if the transmission is ultimately not successful. To determine if and when the file transmission is successful and complete, use onComplete.

In some cases, onProgress listeners are not invoked; for example, if the file being transmitted is very small, or if the upload or download happens very quickly.

File upload progress cannot be determined on Macintosh platforms earlier than OS X 10.3. The onProgress event is called during the upload operation, but the value of the bytesLoaded parameter is -1, indicating that the progress cannot be determined.

Availability: ActionScript 1.0; Flash Player 8

Parameters

fileRef:flash.net.FileReference - The FileReference object that initiated the operation.

bytesLoaded:Number - The number of bytes transmitted so far.

bytesTotal:Number - The total size of the file to be transmitted, in bytes. If the size cannot be determined, the value is -1.

Example

The following example traces the progress of a download using the onProgress event listener.

import flash.net.FileReference;

var listener:Object = new Object();

listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {
    trace("onProgress: " + file.name + " with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal);
}

var fileRef:FileReference = new FileReference();
fileRef.addListener(listener);
var url:String = "http://www.macromedia.com/platform/whitepapers/platform_overview.pdf";
fileRef.download(url, "FlashPlatform.pdf");

See also


Version 8

Comments


snah said on Oct 1, 2005 at 1:12 PM :
I try to make download and use code of this example.
How can I use ProgressBar component to display downloading process?
How is possible to display running the parameters of onProgress function:
bytesLoaded:Number, bytesTotal:Number
Thank you
No screen name said on Jul 12, 2006 at 7:51 PM :
Try this inside you progress listener.


trace ("onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal);
var percent = Math.round ((bytesLoaded / bytesTotal) * 100);
someMovieClip._xscale = percent;

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/8/main/00002219.html