Policy file error while downloading images from facebook

I am doing a game listing on facebook. I do not use the connection, but I work inside the canvas. When I try to upload images from facebook, it gives me the following error.

SecurityError: Error #2122: Security sandbox violation: Loader.content: http://test cannot access http://profile.ak.fbcdn.net/v22941/254/15/q652310588_2173.jpg A policy file is required, but the checkPolicyFile flag was not set when this media was loaded.

Here is my bootloader code

    public var preLoader:Loader;
    preLoader=new Loader();
        **update**
        Security.loadPolicyFile('http://api.facebook.com/crossdomain.xml');
        Security.allowDomain('http://profile.ak.fbcdn.net');
        Security.allowInsecureDomain('http://profile.ak.fbcdn.net');
                    **update-end**


        public function imageContainer(Imagewidth:Number,Imageheight:Number,url:String,path:String) {
        preLoader=new Loader();

        Security.loadPolicyFile("http://api.facebook.com/crossdomain.xml");
        var context:LoaderContext = new LoaderContext();
        context.checkPolicyFile = true;
        context.applicationDomain = ApplicationDomain.currentDomain;

        preLoader.load(new URLRequest(path),context);

Any ideas? I import the correct class though.

UPDATE: I upload images from another domain, for example, I call func http://fahim.com the images from http://profile.ak.fbcdn.net/v22941/254/15/q652310588_2173.jpg something (I made sure that the pictures are static, do not require a facebook login or something else, these are just photos with a public user profile)

+3
source share
4

URL- :

Security.loadPolicyFile('https://fbcdn-profile-a.akamaihd.net/crossdomain.xml');

.

+9
var loaderContext:LoaderContext;
loaderContext= new LoaderContext();
loaderContext.securityDomain=SecurityDomain.currentDomain;
loaderContext.checkPolicyFile = true;

.. loaderContext load()

+3

, facebook - , "*"

.

Security.loadPolicyFile('https://fbcdn-profile-a.akamaihd.net/crossdomain.xml');

+1

, , . . :

backgroundLoader.unload();
backgroundLoader.contentLoaderInfo.addEventListener(Event.INIT,backgroundImageLoaded, false, 0, true);

var lc : LoaderContext = new LoaderContext();
lc.checkPolicyFile = false;
backgroundLoader.load(new URLRequest(imagePath_),lc);

where backgroundLoader is a class variable of type Loader. Then, when it comes to using the image to add it to your canvas, do not request data (do not use e.currentTarget.content), just show the image:

function backgroundImageLoaded(e:Event) : void {
   myMovieClip.addChild(backgroundLoader);
}

(Solution from http://www.onegiantmedia.com/as3--load-a-remote-image-from-any-url--domain-with-no-stupid-security-sandbox-errors )

+1
source

Source: https://habr.com/ru/post/1729455/


All Articles