AIR - File.cancel() - BUG???
I've been trying for the last 3 hours now, but it just does not work. I'm using Flash CS 6, AIR 4.0.0.1390, OS 32-bit XP SP 3.
Scenario:
Using AIR's File, copy a large file to somewhere else "Asynchronously"
Pretty simple!! Here is the BUGGY part: try to show Progress - PROGRESSEVENT DOESN'T WORK. try to listen for canel() method - DOESN'T WORK. here is very simple, straigh-forward code:
import flash.filesystem.File;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.utils.setTimeout;
var a:File = File.desktopDirectory.resolvePath("file1.abc"); //file size: 300+ MB
var b:File = File.desktopDirectory.resolvePath("file2.abc");
a.addEventListener(Event.CANCEL, cn); //DOES NOT FIRE
a.addEventListener(ProgressEvent.PROGRESS, pr); // DOES NOT FIRE
a.addEventListener(Event.COMPLETE, cl);
a.copyToAsync(b, true);
function cn(e:Event):void
{
trace('operation is cancelled');
}
function cl(e:Event):void
{
trace('operation completed');
}
function pr(e:ProgressEvent):void
{
trace(e.bytesLoaded + " " + e.bytesTotal);
}
to make everything pretty simple, I added these two lines:
var c:uint = setTimeout(function ():void {a.cancel(); b.cancel(); trace('cancelled');}, 50); //it traces 'cancelled', I DON'T KNOW wether it really cancels that operation or no
var d:uint = setTimeout(function ():void {b.deleteFile();}, 10000); //even after waiting for 10 seconds, it still shows Error, file is in use...
Here is the Adobe's documentation regarding .cancel() function:
"Cancels any pending asynchronous operation."
Is there any way to STOP/CANCEL current File's operation (such as openAsync, copyToAsync, moveToAsync)???? What if user wants to cancel large file copy??? NO WAY??
