I recently had to load images on from a website that doesn’t contain a crossdomain.xml file. Although it works fine in the authoring environment, it’s quite a pain in the butt when you put it live on a website, suddenly those images don’t show up, or you can’t manipulate them..
The problem arises when you try to access the “content” property of your “Loader” object. It throws a SecurityError.
The solution is quite simple.
just saw this… will try it out. if it works you are amazing !!! 🙂
This is the perfect solution… Thanks!
Works like a charm! Very smooth. Thanks!!
Is this a kind of hack?
the most important thing is it works!Thanks very much!!
Man, I owe you a couple of beers.
It’s fri evening, 20:21 and i’m still in the office trying to work around this problem. Yours is the only solution that actually worked!
It throws a sandbox security error when you try to draw dO to BitmapData. The image does load though!
Works with in Flex as well. Thank you 🙂
I’m not sure, but I think this is loading the image ‘as content’, not ‘as data’. Which is why people are reporting they can see it, just can’t access the pixel data (i.e. when doing a draw to BitmapData). I could easily be wrong, but you can read more here:
Thanks so much for posting this – I’ve been tearing my hair out for hours – your solution is that only one that works for me (picasa api + flashplayer 10)
This is great, thank you for posting this.
Damn this is awesome. I think you just saved my life.
I am eternally greatful.
[…] couple of different things to try and get round this problem most notably Martin Legris’ fix (Getting around the crossdomain.xml file when loading images in as3) but annoyingly nothing I tried would […]
even if there is a crossdomain.xml by default, or loaded with Security.loadPolicyFile, the try fails…
so using the code in the catch is ok…but when trying to draw the displayobject to a bitmapdata, a security error occurs again !
My friend you made a mistake. You can manage the loader, stretch it and rotate, but you cant access bitmap data without crossdomain security. You can copy BitmapData or manage it ((
Nice try. Good idea for using the loader.
[…] A workaround has been found that allows you to get around the issue and display the image on screen. The as3 workaround can be found here. […]
all the above in one line:
loader.load(new URLRequest(“url…/pic.jpg”,new flash.system.LoaderContext(true));
I didn’t notice the catch and try clause
It works again (and it’s my final post)
hi, I wS using your code to load some images and it worked perfectly! until I had to make some transformations on the bitmapdata… I got a security sandbox error telling me I couldnt modify the bitmapdata with draw() for example… after losing some hair I found a solution for it. in fact it’s very straight forward, you just need to make a clone of the image using a bytearray and then reload this bytearray with loader.readbytes()…
a more detailed explanation is on my blog: http://www.inklink.co.at/blog/?p=14
I hope it helps those needing to do some bitmapdata.draw() and alike on crossdomain images…
Wow! Exactly what I have been looking for all day! Modified it a bit to add it to a new sprite centered but at least it works! I couldn’t use a crossdomain on one of my server.
Just wanted to say a big thanks for your solution! High five!
Thanks it workss!! You save my day 🙂
This works !!
THANK YOU!!! I’ve been searching for a this for 2 weeks now. You saved me and my hair. I owe you a beer!