flash cs4 file reference. Event.COMPLETE not called on a MAC,
Posted
by jobbie jones
on Stack Overflow
See other posts from Stack Overflow
or by jobbie jones
Published on 2010-06-16T17:52:18Z
Indexed on
2010/06/16
18:22 UTC
Read the original article
Hit count: 274
Hi,
I am working with a fileReference, however I'm having issues running on Safari on a MAC...
EDIT
The below example also doesnt work on Safari on a MAC...
#
The workflow on a PC runs as such:
1) Create file reference
2) attach addEventListener's for Event.SELECT and Event.COMPLETE
3) call the browse() method
On a PC, Event.SELECT is fired when a file has been selected. Event.COMPLETE is fired when the file data is available to flash. If I select an 500meg file, it takes a few seconds before Event.COMPLETE is fired. If I attempt to access the file data properties (such as reading the data stream) before Event.COMPLETE is fired, I receive null reference errors...
So far so good.
However, on a MAC (speficially Safari, not tested other browsers), the Event.COMPLETE is not fired.
I have checked the Adobe docs, which say Event.COMPLETE is fired when the upload is completed. So why does it get fired on windows when the fileReference has parsed the file, but the upload method has not yet been called...
Can anyone help?
Here's snippets of the code I am working on:
public function browseFile(target:Object):void
{
var imagesFilter:FileFilter = new FileFilter("Allowed files", "*.jpg;*.bmp;*.flv;");
fileReference.browse([imagesFilter]);
fileReference.addEventListener(Event.SELECT, fileSelect);
fileReference.addEventListener(Event.COMPLETE, fileSelectComplete);
}
private function fileSelect(event:Event):void
{
// update label - IMPORTANT for large files as there's a delay while flash parses file, before control is handed back to this script...
setStatusLabel("...loading file");
var fileReference:FileReference = event.target as FileReference;
fileReference.addEventListener(Event.COMPLETE, fileSelectComplete);
// load the file into the fileReference object
fileReference.load();
}
// Called when upload file has been processed by flash (a few secs for large files, or fileRef.data is null...)
private function fileSelectComplete(event:Event):void
{
var fileReference:FileReference=event.target as FileReference;
trace("ready to do things - but not fired on Safari on a MAC ");
}
© Stack Overflow or respective owner