Just in case someone faced the same problem i did. Here’s the actual code to download a file with Flex
var fileToDownload:FileReference = new FileReference();
private function downloadFile(event:MouseEvent):void
{
var request:URLRequest = new URLRequest("file.txt");
fileToDownload.download(request, "aSpecificFilenameChosenByYou.txt");
}
It doesn’t work if your file reference object is declared as a local variable. For the non-coders, here is the negative example.
private function downloadFile(event:MouseEvent):void
{
var request:URLRequest = new URLRequest("file.txt");
var fileToDownload:FileReference = new FileReference();
fileToDownload.download(request, "aSpecificFilenameChosenByYou.txt");
}
#1 by Shell on October 20, 2008 - 8:23 pm
Quote
Thank you Kenneth!
I thought my brains exploding…
Thanks again!
Fu#&ing coders….