gpt4 book ai didi

actionscript-3 - 单击按钮后开始下载的 AS3 功能!

转载 作者:行者123 更新时间:2023-12-01 00:01:33 25 4
gpt4 key购买 nike

我的网站需要一个 actionscript 3 函数,它可以让人们在单击按钮后下载文档。

在网上的任何地方都找不到这个。

谢谢!
詹妮弗

最佳答案

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");
}

关于actionscript-3 - 单击按钮后开始下载的 AS3 功能!,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2972207/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com