File I/O Error not trapped by Event Listener
Doesn't appear that File I/O error is trapped by the IOErrorEvent.IO_ERROR event
as described in all the documentation and samples I've looked at.
My test code is listed below - if the P drive does not exist it generates a File I/O error (#2038)
which it should - but it doesn;'t get trapped in File event.
Here's the simple test code attached to a button
public function btnSubmitSafetySheet_clickHandler(event:MouseEvent):void
var pdfFilter:FileFilter = new FileFilter("PDF Files", "*.pdf"); var tmpPDF:File = File.documentsDirectory.resolvePath("rpt_RegionalManagers.pdf");
var copyToMissingFolder:File = new File();
copyToMissingFolder.nativePath = ("P:/safety/Initials-DDMMYYYY-SafetySheet.PDF");
trace(copyToMissingFolder.nativePath);
if (copyToMissingFolder.exists) {
trace('MissingFolder exists');
}
else {
trace('MissingFolder DOES NOT exist');
}
tmpPDF.addEventListener(IOErrorEvent.IO_ERROR, pdfCopyError)
tmpPDF.copyTo(copyToMissingFolder, true); // Should Generate I/O Error if P: not available
trace('copied to missing docs folder');
}
private function pdfCopyError(evt:IOErrorEvent):void {
trace('PDF Copy From Network Error');
trace('Error Message: ' + evt.text);
removeFileListeners();
}
No trace messages from the IOErrorevent function - just the debug and Error:
P:\safety\Initials-DDMMYYYY-SafetySheet.PDF
MissingFolder DOES NOT exist
Error: Error #2038: File I/O Error.
at flash.filesystem::File/copyTo()
