AS3 UILoader: Load never completed
I am trying to load cover art from movies into UILoader components in Flash CS5. I'm using the IMDB API to retrieve the URL's to these images, but I know for a fact that this code works, and that the URL's are valid (copy-pasting them into a browser shows the images as they should). However, when I set the source of my UILoader component to one of these URL's, I get a "Load never completed" error, and the image will not sh开发者_运维技巧ow up. If I replace the URL with a random other image location not belonging to imdb, it also loads just fine.
The URL's returned by imdb are fairly long and contain several special characters, so I'm guessing it's not loading because of that. Below is the error in question (also contains an example URL):
Error #2044: Unhandled ioError:. text=Error #2036: Load Never Completed. URL: http://ia.media-imdb.com/images/M/MV5BMjE5ODg1NTk3OF5BMl5BanBnXkFtZTcwNzA5NTMyNA@@._V1_SX320.jpg
Any idea on how to get this loaded into a UILoader component?
You cannot use UILoader because the crossdomain on imdb doesn't allow access:
http://ia.media-imdb.com/crossdomain.xml
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*.images-amazon.com"/>
<allow-access-from domain="images.amazon.com"/>
<allow-access-from domain="g-images.amazon.com"/>
<allow-access-from domain="*.ssl-images-amazon.com"/>
<allow-access-from domain="*.amazon.com"/>
<allow-access-from domain="*.bebe.com"/>
<allow-access-from domain="cea.target.com"/>
<allow-access-from domain="xyccea.target.com"/>
<allow-access-from domain="testcea.target.com"/>
<allow-access-from domain="devcea.target.com"/>
<allow-access-from domain="sites.target.com"/>
</cross-domain-policy>
The Loader class can load images cross-domain. It's only restriction is that you can't redraw or modify the image. http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Loader.html?filter_flash=cs5&filter_flashplayer=10.2&filter_air=2.6
If you need to do any modifications can try piping the byteArray to another new Loader().loadbytes(myByteArray). That could bypass the restrictions placed on the first loader.
Here's a quick gist of the idea. https://gist.github.com/1204895
精彩评论