加载在ActionScript上VK.com个人资料图片加载、个人资料、图片、VK

2023-09-08 15:04:58 作者:哥的帅气、值得你拥有

我在vk.com一个iframe应用程序。我可以使用他们的API看起来一切正常,但当我想要加载个人资料图片,我得到一个安全沙箱错误。当我打印结果和错误,我得到这样的:(我用Greensock ImageLoader的)

I have an iframe application in vk.com. I can use their API everything looks fine but when I want to load profile images I get Security Sandbox Error. When I print the result and errors I get This: (I am using Greensock ImageLoader)

MYURL:在VK的cs408919子域MY图片网址 加载跨域标签上cs408919 ScriptAccessDenied:的错误#2048 引发SecurityError:的错误#2048 错误:的错误#2048 ScriptAccessDenied:的错误#2123安全沙箱冲突,没有政策文件授予访问

MYURL : 'MY Image URL on cs408919 subdomain of vk' Loading CrossDomain on cs408919 ScriptAccessDenied : Error #2048 SecurityError : Error #2048 Error : Error #2048 ScriptAccessDenied : Error #2123 Security SandBox Violation, No Policy Files Granted Access

在我看来,crossdomain.xml的问题,但我找不到合适的人。谢谢...

It seems to me crossdomain.xml issue but I couldn't find right one. Thanks...

推荐答案

是的,这是跨域问题,VK子域的图像不提供的crossdomain.xml 的用户头像,但你仍然能够加载(并加入到显示列表以及)他们。什么,你不能做的是访问加载的内容(并设置顺利位图的标志,例如,或的孔舞台上VK图像)。

Yes, it's crossdomain issue, vk sub-domains for images doesn't provide crossdomain.xml for user avatars, but you still able to load (and add to display list as well) them. What you can't do is to access the loaded content (and set smooth bitmap flag for example, or draw the hole stage with vk images on it).

如果您需要访问,你可以用这个政策破解的内容,但它的黑客,所以它可以固定在任何FP更新(我想即使这个答案可能会带来更接近这个时刻:)):

If you need the access the content you can use this "policy-hack", but it's hack, so it can be fixed in any FP update (I guess even this answer may bring closer this moment:) ):

我们的想法是听添加的事件,如果图像加载器:

The idea is to listen the ADDED event if image Loader:

protected var _prepareloaderBitmap:Bitmap;

_prepareloader.addEventListener(Event.ADDED, onPrepareLoader);
_prepareloader.contentLoaderInfo.addEventListener(Event.COMPLETE, onPrepareLoader);

和监听器:

protected function onPrepareLoader(event:Event):void
{
    //event ADDED fired only for Bitmap (not for SWFs)
    if(event.type == Event.ADDED)
    {
        _prepareloaderBitmap = event.target as Bitmap;
    }
    else if (event.type == Event.COMPLETE)
    {
        if(_prepareloaderBitmap)
        {
            trace("loaded image size:", _prepareloaderBitmap.width, "x", _prepareloaderBitmap.height);
        }
    }
}

具有参考装位图您可以现在添加,而不是发出跨域加载它。

Having the reference to the loaded Bitmap you can now add it instead of crossdomain issued loader.