开发者

Cairngorm SequenceTask + URLLoader throws SecurityError because of missing user interaction

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.


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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜