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:
- Generate a BitmapData object drawing the contents of an area of the stage
- 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/)
- 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.