BitmapData/draw() and checkPolicyFile

March 19th, 2008

Today I ran into the following error:

SecurityError: Error #2122: Security sandbox violation: BitmapData.draw: http://exampledomain.com/file.swf cannot access http://exampledomain.com/images/image.jpg. A policy file is required, but the checkPolicyFile flag was not set when this media was loaded.

The error was generated by a class in our util folder that we use quite much, but we never had this problem. Well as the error is mentioning, the checkPolicyFile is not set because the LoaderContext is set to null when you don’t supply one in the Loader.load(request:URLRequest, context:LoaderContext = null):void. The strange thing is that the browser is loading the images, only when I create a bitmap and want to draw() the bitmapData I get the above error. I don’t get why it doesn’t check the policyfile when I request the image from a different domain. In order to get rid of the error I did the following:  

1
2
3
var loaderContext:LoaderContext = new LoaderContext();
loaderContext.checkPolicyFile = true;
Loader(_loader).load(_req,loaderContext)

So adding the loaderContext with checkPolicyFile on true does the trick.


8 Responses to “BitmapData/draw() and checkPolicyFile”

  1. Eric on March 20, 2008 4:13 am

    Having the same problem, but I can’t control the Policy File ( amazon s3 ). Hoping to find a way around this as it’s still not working..

  2. admin on March 20, 2008 10:37 am

    Does s3 provide a crossdomain.xml? Try checking it out with FireBug. As far as I can tell from this article, a crossdomain.xml file is not there by default.

  3. When a Cross-Domain Policy File is not Enough | blog.log2e.com on August 15, 2008 2:03 pm

    [...] web server and it fails. Why? Probably because I have missed to read this article, this blog post, and this blog post. And yes, I admittedly have never paid attention to the existence of the [...]

  4. Flickr, Flash, PV3D, Crossdomain en LoadPolicy | Brian's blog on November 13, 2008 11:53 pm

    [...] informatie vind je hier: Over toegang tot flickr Adobe livedocs Over de policyfile Please [...]

  5. no on February 1, 2009 9:14 pm

    On S3, you could just upload a file keyed “crossdomain.xml”…

  6. ariden on February 4, 2009 1:59 pm

    Yeh, it’s a nice tutorial :)

  7. Dave on March 12, 2009 11:46 pm

    Thanks for this — saved me a bunch of hair pulling.

  8. sandrar on September 10, 2009 2:55 pm

    Hi! I was surfing and found your blog post… nice! I love your blog. :) Cheers! Sandra. R.

Trackback URI | Comments RSS

Leave a Reply

Name (required)

Email (required)

Website

Speak your mind