AS3功能,点击按钮后开始下载! [英] AS3 Function to start download after clicking a button!

查看:108
本文介绍了AS3功能,点击按钮后开始下载!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个我的网站的一个动作脚本3功能,让他们点击一个按钮后下载文档。

I need an actionscript 3 function for my website, that lets people download a document after they have clicked on a button.

净。

谢谢!
Jennifer

Thanks! Jennifer

推荐答案

FileReference :: download()

btn.addEventListener(MouseEvent.CLICK, promptDownload);

private function promptDownload(e:MouseEvent):void
{
  req = new URLRequest("http://example.com/remotefile.doc");
  file = new FileReference();
  file.addEventListener(Event.COMPLETE, completeHandler);
  file.addEventListener(Event.CANCEL, cancelHandler);
  file.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
  file.download(req, "DefaultFileName.doc");
}

private function cancelHandler(event:Event):void 
{
  trace("user canceled the download");
}

private function completeHandler(event:Event):void 
{
  trace("download complete");
}

private function ioErrorHandler(event:IOErrorEvent):void 
{
  trace("ioError occurred");
}

这篇关于AS3功能,点击按钮后开始下载!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆