bufanliu / flexlib

Automatically exported from code.google.com/p/flexlib
0 stars 0 forks source link

Base64Image throwing error when using url as source #64

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Add a Base64Image to your app
2. save a file in the web app at a similar location 
'http://localhost:8080/WebApp/main/assets/
temp/hdsjuhyts.jpg'
3. assign the url to the source property
4. depending on the string of the url, you will receieve a non valid image 
error or a broken link 
error.

What is the expected output? What do you see instead?
Assuming the url is valid the string should be sent to the super (Image 
component) and load the 
image.  However, instead the string is getting interpreted as a Base64 string 
and the code is 
attempting to convert it to an image.  As we were trying to debug this problem 
we came up with 
two possible solutions.

1) First try to load any string under a certain length as a URL. Catch the 
error and then try to load 
as Base64.

2) Catch the error thrown after the url is erroneously decoded as if it were 
base64 and then try to 
load the URL as a path string.

What version of the product are you using? On what operating system?
Flex 2.0.1, Mac OS X & Windows XP

This error was hard to debug since it really depends on the value of the url 
string.  For example, 
certain URL strings would work fine and then others would throw the error.  We 
are thinking it 
depended on the length of the string as to whether the URL would be interpreted 
correctly or as 
a Base64 string.  Feel free to contact us through flexcoders if any questions 
since it took us a 
while to crack this!

- Kevin M

Original issue reported on code.google.com by onefootp...@gmail.com on 7 Dec 2007 at 3:15

GoogleCodeExporter commented 8 years ago

Original comment by dmcc...@gmail.com on 25 Dec 2007 at 2:35

GoogleCodeExporter commented 8 years ago
Original error checking for Base64Image relied on an error being thrown by
Base64Decoder.decode(), which would then load the image using the normal 
Image.source
property. However, sometimes Base64Decoder did not throw an error and decoded 
fine
(even if the string was not meant to be a base 64 image), but then the Loader 
would
thrown an uncaught IOErrorEvent and the component would fail silently.

Instead, we should add an IOErrorEvent listener on the loader and if an 
IOErrorEvent
gets thrown then default to using super.source.

Original comment by dmcc...@gmail.com on 25 Dec 2007 at 5:51

GoogleCodeExporter commented 8 years ago

Original comment by dmcc...@gmail.com on 26 Dec 2007 at 11:11

GoogleCodeExporter commented 8 years ago

Original comment by dmcc...@gmail.com on 26 Dec 2007 at 11:32

GoogleCodeExporter commented 8 years ago

Original comment by dmcc...@gmail.com on 3 Jan 2008 at 8:30