AS3/flex

Tuesday, December 1, 2009

18 image upload

The requirement was like this.

There will be 18 icons, clicking on each will open a browse window, after selection, the image will be shown in place of the icon as a thumb. Then there will be a Upload All button which will upload all images one by one. During upload it will show the progress in a progress window.


It was simple and took around 10 hours to complete,

then came a bug !

When user selects an image higher than 5mb the application crashes !
after a some google i found out this:
Adobe flash player 10 has certain limitations for pixel ratio to show images the max supported resolution is 4,095 x 4,095 pixels
so the files exceeding this size makes the browser crash when we try to bitmap it!
reference: http://kb2.adobe.com/cps/496/cpsid_49662.html

So what we did is, checked the resolution just after selection and created a popup window to alert user to select a smaller file (less than 4,095 x 4,095) and we fixed it !

then we got a new task to add a resolution limit, a higher limit and a lower limit and we updated it in a matter of hour.
And we got another bug !
There was a special image, size 2.1MB resolution higher than limit but flash shown it as lower limit error !!
And it made us stunned ! We took the image and tested in our end and found same result. The image seemed wired. One sixth area of the image contains the actual image and the rest contains white space!
We googled and did a lot research on the image but all of them led us to nowhere !
We got so many questions like
What if all the bad images user selects are like this? higher size image showing lower size error is funny !! So we finally settled up with an idea to show a common error for both higer and lower limit. And the bug got fixed !
Then some language changes and quick bugs and application ready!
No !!
We got another task !
The images needed to be resized at client end . To optimize both user and server's bandwidth!
First it seemed simple but flash player got so many security features that made us stand on our knees :(
first one is
FileReference.data is a read only property! Which means the application cannot modify and upload selected file using FileReference.
So what we planned is convert the bitmap into jpeg byte array and send it to server using URLLoader/URLStream.
It worked fine but another security error came up !
A ByteArray data can only be sent by a user event like mouse click/button click! where as we have to send the files one after another serially !
So when we implemented our plan in the application only first image got uploaded showing a security 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.
at flash.net::URLStream/load()
at flash.net::URLLoader/load()

next to be updated after we fix it . please suggest us if you have any fixes !

No comments:

Post a Comment

Followers