Is there any particular reason why onSelect won't fire even after a file has been selected?
Here's what I'm working with:
public function uploadFile():void{
var fileref: FileReference = new FileReference();
fileref.addEventListener(Event.SELECT, onSelect);
fileref.browse([new FileFilter("Documents", "*.pdf;*.doc;*.txt;*.rtf")]);
}
private function onSelect(e:Event):void{
trace("well whaddya know? it worked!");
}
Came across this in the docs: > if the FileReference object goes out of scope, any upload or download that is not yet completed on that object is canceled upon leaving the scope. Be sure that your FileReference object remains in scope for as long as the upload or download is expected to continue.
So that says it's a scoping issue. Thing is, it still doesn't work:
var _fileref:FileReference = new FileReference();
private function uploadFile():void{
_fileref.addEventListener(Event.SELECT, onSelect);
_fileref.browse([new FileFilter("Documents", "*.pdf;*.doc;*.txt;*.rtf")]);
}
private function onSelect(e:Event = null):void{
trace("well whaddya know? it worked!");
}
:(
All righty... It looks as though a SELECT event only fires when the swf is in a browser. I'm assuming the same holds true for other types.
ass.pain++;
Originally posted by: baron ruhstoff All righty... It looks as though a SELECT event only fires when the swf is in a browser. I'm assuming the same holds true for other types.
ass.pain++;
Contributing further to the wtf quotient is the fact that the problem only occurs on a Mac. On a PC, running standalone through the IDE works fine.
i think i ran into this issue a while ago. It's got something to do with the FileReference object being garbage collected too early. If you define the object in your applications scope, rather than inside a method it should work. e.g
var fileRef:FileReference;
function browse():void { fileRef = new FileReference(); // other stuff here. }
rather than
function browse():void { var fileRef:FileReference = new FileReference(); // other stuff here. }
hope it helps,
A.
[edit]Looks like you already tried that. Bummer
[/edit]
Thanks anyway! :thumbsoup: