PDA

View Full Version : SecurityError: Error #2122: Security sandbox violation


panel
02-26-2008, 04:12 PM
Hi

I have issue with loading images

This works

var loader:Loader = new Loader();
loader.load(new URLRequest("http://l.yimg.com/www.flickr.com/images/tour/hp_1.jpg"));
loader.contentLoaderInfo.addEventListener(Event.IN IT, onInit);

function onInit(evt:Event):void
{
addChild(loader)
}

Here is sample
http://oceanic.wsisiz.edu.pl/~hamela/Igor/NoBitmap.html

This Do Not Work
If I try to make any changes to image like this

var loader:Loader = new Loader();
loader.load(new URLRequest("http://l.yimg.com/www.flickr.com/images/tour/hp_1.jpg"));
loader.contentLoaderInfo.addEventListener(Event.IN IT, onInit);

function onInit(evt:Event):void
{
var bitmap:Bitmap = (evt.target.content);
if (bitmap != null)
{
bitmap.smoothing = true;
}
addChild(bitmap);
}


error appears in debug version of FlashPlayer and image never appears ;/

SecurityError: Error #2122: Security sandbox violation: LoaderInfo.content: http://oceanic.wsisiz.edu.pl/~hamela/Igor/Bitmap.swf cannot access http://l.yimg.com/www.flickr.com/images/tour/hp_1.jpg. A policy file is required, but the checkPolicyFile flag was not set when this media was loaded.
at flash.display::LoaderInfo/get content()
at Bitmap_fla::MainTimeline/onInit()


Here is sample
http://oceanic.wsisiz.edu.pl/~hamela/Igor/Bitmap.html

:confused:

jaga
02-26-2008, 04:46 PM
You want to use a LoaderContext when loading, to ensure manipulation outside of the local sandbox..

look up the LoaderContext class, and use it as the 2nd argument in the load() function

panel
02-26-2008, 05:11 PM
Oki dit is and worked :)

but there is another issue

I am loading images from

www.i.myDomain.com/Image1.jpg


and now it wants to load crossdomain xml from

www.i.myDomain.com/crossdomain.xml

Unfortunetly it isn't imposible to put crossdomain file there, becouse this url is created at cahce proxy level, and it's kind of vistual url.

Is there any way to change crossdomain.xml path?
ex for

www.abc.myDomain.com/crossdomain.xml

jaga
02-26-2008, 05:30 PM
Security.loadPolicyFile(url)

panel
02-27-2008, 02:10 PM
Thanks jaga :)