Skip to main content
February 3, 2011
Answered

download file from server

  • February 3, 2011
  • 1 reply
  • 1043 views

hey there, how do I initiate the download function in ActionScript3.0.?

(Where a dialogue box will be opened to let my users download a file  from my server)

This topic has been closed for replies.
Correct answer Kenneth Kawamoto

var download_btn;


download_btn.addEventListener(MouseEvent.CLICK , downloadFunction);
function downloadFunction(event: MouseEvent)
{
    var request:URLRequest = new URLRequest('http://www.yoursite.com/downloads/filename.zip');
    navigateToURL(request);
}

import flash.net.URLRequest;
import flash.net.FileReference;

download_btn.addEventListener(MouseEvent.CLICK , downloadFunction);
function downloadFunction(event: MouseEvent):void {
    var req:URLRequest = new URLRequest('http://www.yoursite.com/downloads/filename.zip');
    new FileReference().download(req);
}

1 reply

Kenneth Kawamoto
Community Expert
Community Expert
February 3, 2011

Use FileReference.download()

February 3, 2011

ok, I'm new to Flash. Where do insert the directory of the file itself?

Kenneth Kawamoto
Community Expert
Community Expert
February 3, 2011
new FileReference().download(new URLRequest("URL of your file"));

Please note this can only be done upon user interaction such as button click.