我的网站需要一个 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");
}
关于actionscript-3 - 单击按钮后开始下载的 AS3 功能!,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2972207/