FileReference.download() in SWF file fails
This stung me last night and I searched a fair bit to find out why. Kinda obvious I guess.
I am posting a link to the Adobe Technote and pasting a bit of it straight here.
From Adobe Technote
To allow a FileReference instance to accept a response, it needs to be defined in a persistent scope. This requires that the instance be defined either within the timeline of your movie or as a property of your class and not within the local scope of a function call.
Will not work
function downloadFile():void {
var fileRef:FileReference = new FileReference();
fileRef.download(new URLRequest("myFile.txt"), "myFile.txt");
}
This will
var fileRef:FileReference = new FileReference();
fileRef.download(new URLRequest("myFile.txt"), "myFile.txt");
}
var fileRef:FileReference = new FileReference();
function downloadFile():void {
fileRef.download(new URLRequest("myFile.txt"), "myFile.txt");
}
function downloadFile():void {
fileRef.download(new URLRequest("myFile.txt"), "myFile.txt");
}

Visit
Thanks for blogging it.