Select to view content in your preferred language

SecurityError: Error #2122: Security sandbox violation: BitmapData.draw

1013
2
12-29-2010 11:59 AM
RobertScheitlin__GISP
MVP Emeritus
Viewer or API Team,

   I ran into a interesting situation today playing with the FlexViewer. I used the Traffic Camera (query widget) and displayed some traffic camera results and then went to print the map and got this application error:

SecurityError: Error #2122: Security sandbox violation: BitmapData.draw: http://gislap134/FlexViewer2.2/index.swf/[[DYNAMIC]]/2 cannot access http://www.trimarc.org/images/snapshots/CCTV016.jpg. A policy file is required, but the checkPolicyFile flag was not set when this media was loaded.

Any ideas?
Tags (2)
0 Kudos
2 Replies
FernandoPanetta
Emerging Contributor
Hi,
I have the same problem today! There is a solution pleace?
Thanks Michele
0 Kudos
FernandoPanetta
Emerging Contributor
Hi,
today I investigated for this problem and I discovered that possible solution: crossdomain.xml into server where are the pictures.
For exsample the picture of flicker use different crossdomain:

http://api.flickr.com/crossdomain.xml
http://farm1.static.flickr.com/crossdomain.xml
http://farm2.static.flickr.com/crossdomain.xml
http://farm3.static.flickr.com/crossdomain.xml
http://farm4.static.flickr.com/crossdomain.xml

For call the crossdomain you must set a "Security.loadPolicyFile(url)" !!

I have modify the infoPopupWidget for auto-load a crossdoamin.xml for every site (if crossdomain exsist into server) creating a function:


private function security():void
{
var str:String = data.link;
var myArr:Array = str.split("/");
var crossdomainUrl:String = myArr[0] +"//" + myArr[2] + "/crossdomain.xml"
Security.loadPolicyFile(crossdomainUrl);
}

I call this function in dataChangeHandler() function :

private function dataChangeHandler(event:FlexEvent):void
{
if (data == null)
{
return;
}

_title = data.title || "";
_content = data.content;

if (_content)
{
infoContent.visible = true;
}

//clear picture and link button
infoImage.source = "";
infoImage.visible = false;
infoImage.includeInLayout = false;
infoLink.visible = false;
infoLink.includeInLayout = false;

if (data.link)
{

security();

var link:String = data.link as String;
var pos:Number = link.length - 4;
var sfx:String = link.substr(pos, 4).toLowerCase();
if ((sfx == ".jpg") || (sfx == ".png") || (sfx == ".gif"))
{
infoImage.source = link;
infoImage.visible = true;
infoImage.includeInLayout = true;
}
else
{
infoLink.text = link;
infoLink.visible = true;
infoLink.includeInLayout = true;
}
}
}

This trips function for each site where is a crossdomain but I have a problem if there not exist !!

Any suggestions to solve the problem?

Thanks

Michele
0 Kudos