AS3/Flex FileReference download problem - solved
If the file reference object is created as a function local variable the download save box appears but the file is never saved.
The solution is documented on the Adobe knowledgbase: FileReference.download() in SWF file fails and I found it via this thread.
The long and short of it is:
Problem code (note the fileRef is inside the function):
var fileRef:FileReference = new FileReference();
fileRef.download(new URLRequest("myFile.txt"), "myFile.txt");
}
function downloadFile():void {
fileRef.download(new URLRequest("myFile.txt"), "myFile.txt");
}
Hope it saves someone some time - or increases the chances of the technote being found quickly via google.
Cheers, Mark




I had the same problem and ended up implementing the full example provided in the Flex 3 docs. The weird thing was it seemed to work and the stopped functioning a week later, but it could have been my imagination. At least now I know it wasn't me - exactly :-)
Richard
Thanks to you and Google. Life is easier.:)
Very useful link, thank you!
gracias amigo
Thx :)
i'm ready to cry. I thought I must be incredibly dumb. Thank you! Thank you! Thank you!
Refactoring broke my stuff!!
Many Thanks!
Kiitos
please check this example under the below link:
http://www.acoukess.info/bernard/download-in-AS3.z...
please check this example under the below link:
http://www.acoukess.info/bernard/download-in-AS3.z...