2010-01-21 69 views
3

我在Facebook上制作游戏排行榜。我没有使用连接,但在画布内工作。当我尝试从Facebook加载图像时,它给了我下面的错误。加载图片时出现策略文件错误facebook

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. 

这里是我的装载代码

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); 

什么想法?我正在导入正确的课程。

UPDATE: 我从不同的域说加载图像,调用FUNC http://fahim.com图像是从http://profile.ak.fbcdn.net/v22941/254/15/q652310588_2173.jpg东西(我已经确定的图片是静态的不需要Facebook登录或任何东西,他们只是用户公开资料图片)

+0

如果你是从Facebook加载,那么你为什么从felinefrenzy.com加载策略文件? – Amarghosh 2010-01-22 04:25:06

+0

@Amarghosh,对不起,我没有更新那里。在我原来的代码中,我使用的是facebook crossdomain。我刚刚更新了。它仍然给我完全相同的错误。 @ sberry2A,是的,我需要更改名称,我现在正在使用不同的网址,然后是facebook提及等等。虽然所有的变化仍然给我同样的错误。 – 2010-01-22 07:06:55

+0

你确定这行吗'context.checkPolicyFile = true;'?是原始代码本身的一部分吗?在所述位置的政策文件似乎没问题。 – Amarghosh 2010-01-22 13:49:40

回答

1

得到它的工作,对图像Facebook的政策文件是在其他地方都被我拒绝一切以“*”

感谢大家的帮助。

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

+1

什么是Facebook政策文件的图像的网址? – 2011-05-08 10:57:27

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

..then通的LoaderContext调用load()

9

这是URL到图像策略文件时:

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

这条线就可以工作得很好。

+4

你在聚会上一定很有趣。 – 2012-03-29 09:16:37

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); 

其中backgroundLoader是Loader类型的类变量。然后,当它涉及到使用图像将其添加到您的帆布上,不请求数据(不使用e.currentTarget.content),只显示图像:

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

(解决方案从http://www.onegiantmedia.com/as3--load-a-remote-image-from-any-url--domain-with-no-stupid-security-sandbox-errors