我在 facebook 上制作游戏排行榜。我没有使用连接,而是在 Canvas 内工作。当我尝试从 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);
有任何想法吗?不过,我正在导入正确的类(class)。
更新:
我正在加载来自不同域的图像,比如调用 func http://fahim.com图片来自 http://profile.ak.fbcdn.net/v22941/254/15/q652310588_2173.jpg一些东西(我已经确保图片是静态的,不需要 Facebook 登录或任何东西,它们只是用户公开的个人资料图片)
最佳答案
这是图像策略文件的 URL:
Security.loadPolicyFile('https://fbcdn-profile-a.akamaihd.net/crossdomain.xml');
有了这条线,一切都应该正常工作。
关于flash - 从 Facebook 加载图像时出现策略文件错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2112823/