Sunday, October 16, 2011

Security sandbox violation: BitmapData.draw

While developing the site http://www.ibentointernational.com/ using Papervision3d API, I used customised video player on home page and it starts playing when home page loads.

var myNetStream:NetStream = new NetStream(myNetConnect);
var VideoMc:Video = new Video();
VideoMc.attachNetStream(myNetStream);
var MetaObj:Object = new Object();
myNetStream.client = MetaObj;
MetaObj.onMetaData = OnMetaData;
addChild(VideoMc);

The video was around 40 MB. Most of the time user doesn’t watch full video and they click on pause button to stop video. But after click on pause button video keeps streaming and it increases data transfer of the site. So to reduce data transfer I used myNetStream.close(); script on pause the button instead of myNetStream.pause();
But then its keep throwing below error

SecurityError: Error #2123: Security sandbox violation: BitmapData.draw:
http://www.ibentointernational.com/homepage.swf cannot access unknown URL. No policy files granted access.

I searched online solution for this but I didn’t get.
Then I decided to remove VideoMc from display list whenever NetStream.close() and to add display list whenever it plays.

For this I write script on Play button;
if(myNetStream.bytesLoaded<1){
  myNetStream.play(“showreel.flv”);
  addChild(VideoMc);
}
myNetStream.resume();

On Pause Button
addChild(VideoMc);
myNetStream.close();


It’s working. Is there any other solution besides this?