我的网站需要一个 ActionScript 3 函数,让人们在单击按钮后下载文档。
在网上任何地方都找不到这个。
谢谢!
詹妮弗
文件参考::下载() http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/FileReference.html#download%28%29
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");
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)