Getting around the crossdomain.xml file when loading images in as3

22 actionscript,as3,flash,work  |   February 19, 2008  |     2835

Hi Guys,

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.


  • March 14, 2008 at 3:39 pm


    just saw this… will try it out. if it works you are amazing !!! 🙂

  • May 15, 2008 at 6:14 pm


    This is the perfect solution… Thanks!

  • June 4, 2008 at 8:45 pm


    Works like a charm! Very smooth. Thanks!!

  • July 29, 2008 at 10:24 pm


    Is this a kind of hack?
    the most important thing is it works!Thanks very much!!

  • January 30, 2009 at 1:22 pm


    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!

    High Five!!

  • February 2, 2009 at 11:00 pm


    It throws a sandbox security error when you try to draw dO to BitmapData. The image does load though!

  • February 12, 2009 at 10:54 pm

    Amir Naher

    Works with in Flex as well. Thank you 🙂

  • May 27, 2009 at 2:38 am


    Nice work!

    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:

  • June 9, 2009 at 4:05 pm


    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)

  • August 9, 2009 at 9:37 pm

    Dubi Kaufmann

    This is great, thank you for posting this.

  • October 8, 2009 at 10:33 am


    Damn this is awesome. I think you just saved my life.

    I am eternally greatful.

  • November 9, 2009 at 5:16 pm

    Crossdomains, Sandboxes, and Proxies | VISUAL DIALECTS

    […] 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 […]

  • November 17, 2009 at 8:06 am


    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 !

  • December 31, 2009 at 6:45 am


    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.

  • March 5, 2010 at 1:03 pm

    How to load external images in Actionscript 3 without needing crossdomain.xml file

    […] 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. […]

  • September 18, 2010 at 4:09 pm



    all the above in one line:
    loader.load(new URLRequest(“url…/pic.jpg”,new flash.system.LoaderContext(true));

  • September 19, 2010 at 6:14 am


    I didn’t notice the catch and try clause
    It works again (and it’s my final post)

  • November 7, 2010 at 11:09 am


    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:

    I hope it helps those needing to do some bitmapdata.draw() and alike on crossdomain images…


  • June 13, 2012 at 1:55 pm


    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!

  • April 3, 2014 at 8:37 pm


    Thanks it workss!! You save my day 🙂

  • September 16, 2014 at 8:57 pm

    Mitesh Sharma

    NICE !!
    This works !!

  • December 1, 2014 at 3:11 pm


    THANK YOU!!! I’ve been searching for a this for 2 weeks now. You saved me and my hair. I owe you a beer!

Leave a Reply