View comments | RSS feed

cancel (FileReference.cancel method)

public cancel() : Void

Cancels any ongoing upload or download operation on this FileReference object.

Availability: ActionScript 1.0; Flash Player 8

Example

The following example downloads approximately half of the requested file and then cancels the download. This is obviously not a typical usage. You might more often use this method to allow users to click Cancel in a download status dialog box.

import flash.net.FileReference;

var listener:Object = new Object();

listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {
    trace("onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal);
    if(bytesLoaded >= (bytesTotal / 2)) {
        file.cancel();
    }
}

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");

Version 8

Comments


No screen name said on Sep 28, 2006 at 9:50 PM :
I've encounterd a bug [may be] with fileReference.cancel() method causing an IO Error event to fire when invoked during a upload. This only happens when I upload a relatively large files [few MB] to internet location [low speed] and does not occur with localhost. Is there anyone who may join my club?

 

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/00002207.html