I’m trying to allow users to download a song based on a radio button selection. And I’ve succeeded in getting the “save as” box to pop up, but for some reason, the file does not actually download and save after you hit the save button.
This is the code:
stop();
var fileURL:String = userAnswer;
var fileName:String = "Select a Name for Your Song";
var request:URLRequest = new URLRequest( fileURL );
var fileReference:FileReference = new FileReference();
downloadBtn.addEventListener(MouseEvent.CLICK,onReleaseMyButton);
function onReleaseMyButton(event:MouseEvent):void {
// Add event listeners to the fileReference object here //
fileReference.download( request, fileName );
}
function downloadProgressHandler(event:ProgressEvent){
var percentage = Math.round((event.bytesLoaded/event.bytesTotal)*100);
status.text = "Downloading " + percentage + "%";
}
Can anyone help me?
EDIT: Someone informed me that if the variables weren’t defined OUTSIDE of the function then they would be garbage collected. I moved them outside but it is still behaving the same. Any suggestions, please?