AS3: Download a File to the Desktop


/ Published in: ActionScript 3
Save to your folder(s)

Here's a simple example of how a user can download their file to their desktop


Copy this code and paste it in your HTML
  1. private var request:URLRequest;
  2. private var localRef:FileReference;
  3.  
  4. protected function buttonClick():void
  5. {
  6. request = new URLRequest("soundbyte.mp3");
  7. localRef = new FileReference();
  8.  
  9. try
  10. {
  11. // Prompt and downlod file
  12. localRef.download( request );
  13. }
  14. catch (error:Error)
  15. {
  16. trace("Unable to download file.");
  17. }
  18. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.