问题
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 : '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
It seems to me crossdomain.xml issue but I couldn't find right one. Thanks...
回答1:
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).
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);
And the listener:
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.
回答2:
In additional to fsbmain's answer I want say you have to add following code:
Security.allowDomain("*");
来源:https://stackoverflow.com/questions/16632476/loading-profile-images-on-vk-com-in-actionscript