BitmapData/draw() and checkPolicyFile
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.
Filed under Actionscript 3, Error handling AS3, Flash, Flex |8 Responses to “BitmapData/draw() and checkPolicyFile”
Leave a Reply
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..
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.
[...] 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 [...]
[...] informatie vind je hier: Over toegang tot flickr Adobe livedocs Over de policyfile Please [...]
On S3, you could just upload a file keyed “crossdomain.xml”…
Yeh, it’s a nice tutorial
Thanks for this — saved me a bunch of hair pulling.
Hi! I was surfing and found your blog post… nice! I love your blog.
Cheers! Sandra. R.