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 | Comments (8)