Jen*_*erg 4 file download button actionscript-3
我的网站需要一个actionscript 3功能,让人们在点击按钮后下载文档.
无法在网上找到这个.
谢谢!詹妮弗
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");
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7223 次 |
| 最近记录: |