凯恩戈姆序列任务 +由于缺少用户交互,URLLoader 抛出 SecurityError

发布于 2024-10-26 02:31:13 字数 924 浏览 6 评论 0原文

我正在尝试让应用程序上传多个客户端生成的图像(不是文件,因此我无法使用 FileReference),同时显示上传进度。事实证明,这比应有的要困难得多。我正在使用 Cairngorm 任务库对客户端生成的图像执行以下步骤:

  1. 生成一个 BitmapData 对象,绘制舞台区域的内容
  2. 将图像异步编码为 JPEG,以显示进度条(请参阅 http://dgrigg.com/blog/2009/03/ 05/as3-jpegencoder-and-big-images/
  3. 异步上传图像(分块,参见http://soenkerohde.com/2010/01/chunk-file-upload/) 显示进度

当用户单击按钮时,SequenceTask 启动,编码就像魅力一样,但是当上传任务发生时,它突然起火,并出现错误:

安全错误:错误#2176:某些操作(例如显示弹出窗口的操作)只能在用户交互时调用,例如通过单击鼠标或按下按钮。

我相信发生这种情况是因为如果没有用户干预,您无法启动 URLLoader.load 操作。即使用户正在单击按钮,我认为由于事情开始异步发生,因此该单击事件不再被视为发起者。

有没有办法让URLLoader知道这是鼠标点击的结果?这对于分块上传的工作是必不可少的,因为所有后续块也将启动一个新的 URLLoader,所以我不能 100% 确定参考中的分块上传器确实有效。我可能会尝试先运行他们的纯代码。

感谢您的任何想法。

I am trying to get an application to upload multiple client side generated images (not files, hence I can't use FileReference), while displaying the progress of the upload. This has proved to be way harder than it should be. I am using Cairngorm Task library to perform the following steps on an image generated on the client:

  1. Generate a BitmapData object drawing the contents of an area of the stage
  2. Encode the image as a JPEG asynchronously, as to show a progress bar (see http://dgrigg.com/blog/2009/03/05/as3-jpegencoder-and-big-images/)
  3. Upload the image asynchronously (chunked, see http://soenkerohde.com/2010/01/chunk-file-upload/) to show progress

When the user clicks a button, the SequenceTask gets started, the encoding works like a charm, but when the uploading task occurs, it bursts into flames with the error:

SecurityError: Error #2176: Certain actions, such as those that display a pop-up window, may only be invoked upon user interaction, for example by a mouse click or button press.

I believe this is occurring because you cannot initiate a URLLoader.load action without user intervention. Even though the user is clicking on the button, I think because things start happening asynchronously this click event is no longer being considered as the originator.

Is there a way to let URLLoader know that this is the result of the mouse click? This will be indispensable for the chunked upload to work, because all of the subsequent chunks will initiate a new URLLoader as well, so I'm not 100% sure the chunked uploader from the reference actually works. I might try running just their plain code first.

Thanks for any ideas.

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

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

发布评论

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

评论(3

你另情深 2024-11-02 02:31:13

您必须更改应用程序流程才能在上传之前强制进行用户交互。

此行为是在 Flash Player 10 上引入的(我几乎可以肯定 Flash Player 9 上的 URLLoaders 不会发生这种情况)并且没有办法规避它,否则这将是一个主要的安全漏洞。调度“假”鼠标事件将不起作用,上传/POST 必须在捕获用户交互(鼠标单击或键盘快捷键)的同一调用堆栈上完成。

有关详细信息,请查看“Flash Player 10 中的用户交互要求”

You have to change your application flow in order to force a user interaction before the upload.

This behaviour was introduced on Flash Player 10 (I'm almost sure this didn't happen with URLLoaders on Flash Player 9) and there's no way to circumvent it, otherwise it would be a major security hole. Dispatching "fake" mouse events will not work, the upload/POST has to be done on the same callstack where the user interaction (mouse click or keyboard shortcut) is captured.

Check "User interaction requirements in Flash Player 10" for more information.

╭ゆ眷念 2024-11-02 02:31:13

您可以通过分派 MouseEvent 对象来模拟用户操作吗?

我尝试过通过调用它来执行 FileReference.save() (它并不意味着在没有用户交互的情况下工作),但它有效,所以也许我的配置有一些不同

Could you mimic the user action by dispatching a MouseEvent object?

I've tried doing a FileReference.save() on my end just by calling it (it's not meant to work without an user interaction), but it works, so maybe there's something different with my configuration

反目相谮 2024-11-02 02:31:13

我现在遇到了和你一样的问题。我有几张图片,只有第一次上传像魅力一样工作,但在第二次上传中,它不再出现以下错误:“SecurityError:错误#2176”,并且观看您的帖子我意识到这是由于第二次上传的内部调用所致而不是用户交互。

我尝试过很多选项,其中之一是在开始下一次上传之前使用 close() 关闭 URLloader 并出现相同的错误。诀窍是模拟用户交互。

I am now with the same problem than yours one. I have several images and only the first upload work like a charm but in the second upload, it's stopped arising the following error: "SecurityError: Error #2176", and watching your post i realized that it's due to an internal call the second upload instead of a user interaction.

I have tried with many options, one of then were closing the URLloader with close() before starting the next upload and the same error. The trick is emulating a user interaction.

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