FileReference.save 方法中出现错误

发布于 2024-12-25 22:26:11 字数 347 浏览 2 评论 0原文

我目前正在使用 Flex 3.0,但遇到错误(屏幕截图如下)。我正在使用 Flash Player 版本 10.0

目前,我正在调用 HTTPService,并且在该 HTTPService 的 resultHandler 中,我在方法 filereference.save() 中收到错误。因为只有当 MouseEvent 或 Keyboard 事件发生时才会调用此方法。

是否有任何解决方案可以克服这种情况,或者换句话说,调用 ResultHandler 中的 filereference.save 方法。

在此处输入图像描述

I am currently working in Flex 3.0 I am getting an error(screen shot is given below). I am using Flash Player Version 10.0

Currently I am calling the HTTPService and in the resultHandler of that HTTPService i am getting an error in method filereference.save() . because this method is called only when the MouseEvent or Keyboard event is occured.

Is there any solution to overcome this situation or in other words calling the filereference.save method in ResultHandler.

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

提赋 2025-01-01 22:26:11

原因是您不再被允许自动触发显示文件保存弹出窗口,除非用户通过用户生成的事件实际请求此操作。以下是有关该主题的更多信息: http ://www.bogdanmanate.com/2010/05/12/flex-error-2176-when-using-filereference/

我使用帖子中描述的解决方案解决了这个问题,即通过使用“是/否”警报,向用户表明文件已完成加载并且可以下载,最后要求用户确认是否要将其保存在本地。您可能认为这对用户不友好,但这确实与安全有关。一旦您知道如何触发该事件,您就可以找出绕过此 UI 问题的方法。

祝你有美好的一天!

The reason for this is that you are no longer allowed to automatically trigger the display of file saving popups, except in the event of the user actually requesting this, via an event generated by the user. Here is some more info on the subject: http://www.bogdanmanate.com/2010/05/12/flex-error-2176-when-using-filereference/

I got around this problem using the solution described in the post, namely by using a Yes/No alert, to indicate to the user that the file has finished loading and it is ready for download and finally by asking him to confirm that he wants to save it locally. You might consider thins user-unfriendly, but it's really about security. And once you know how to trigger the event, you can figure out ways of bypassing this UI issue.

Have a great day!

白云不回头 2025-01-01 22:26:11

你不能。您需要用户单击按钮才能完成它。调度 MouseEvent 是没有用的。罗米的方法可以帮助你。但出于安全原因,您需要通过单击按钮来实现。

我所做的就是在结果中检索文件位置并像打开 html 页面一样打开它。然后就可以下载了。除了像 Romi 所说的那样强迫用户单击按钮之外,我认为没有其他解决方案。

var u:URLRequest = new URLRequest(event.result); 
navigateToURL(u, "_blank");

You cannot. You need a click button of the user to get it done. Dispatching a MouseEvent is useless. Romi approach coud help you. But you need for security reasons to made it for a button click.

What I did.. was in the result retrive the file location and open it like an html page. Then you can download it. I see no other solution than forcing the user to click a button like Romi said.

var u:URLRequest = new URLRequest(event.result); 
navigateToURL(u, "_blank");
魂归处 2025-01-01 22:26:11

另一种解决方案可能是将文件发送到服务器,然后让服务器将其发送回客户端,这将触发浏览器的保存/打开对话框。但如果文件是由 flex 创建的,那么这在带宽方面并不理想。

An alternative solution might be to send the file to the server, then have the server send it back to the client which should trigger the browser's save/open dialog box. But if the file is created by flex then this is not ideal bandwidth-wise.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文