2008
06.22

I was really struggling to find a fix for this whilst working on www.fortheloveofbeer.com.au so I thought I would post something here – to keep the transitions fast I had to take a bitmap of my screens (cacheAsBitmap just doesn’t seem to cut the mustard when you have a lot of text on stage) but I kept getting the following error;

SecurityError: Error #2123: Security sandbox violation: BitmapData.draw: http://blah/main.swf cannot access unknown URL. No policy files granted access.

I tried every security fix I could think of but nothing helped. Trying to bitmap draw a screen with a custom video player component was causing the problem. If I tried to do the bitmap draw before an flv was loaded it would throw this error. Turns out that the NetStream object requires onCuePoint and onMetaData handlers to be defined or you will get this error. Why this should result in a security error I’ve no idea but if you come accross this problem yourself try the following and you should have a solution;

var clientObject:Object = new Object();
clientObject.onCuePoint = onCuePoint;
clientObject.onMetaData = onMetaData;

netStream = new NetStream(connection);
netStream.client = clientObject;

private function onCuePoint(e:Object):void {};
private function onMetaData(e:Object):void {};

If you get this problem yourself please leave me a comment letting me know… I couldn’t seem to find anything about this when I was looking for a solution.

Bookmark:
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • StumbleUpon

2 comments so far

Add Your Comment
  1. Hello,

    just add listener to AsyncError to your NetStream :

    netStream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);

    private function asyncErrorHandler(e:AsyncErrorEvent):void {}

  2. Maybe handy to know, a listener is maybe not the only fix you need. Because if you are using the NetStream to connect to a Flash Media Server it needs not only a crossdomain.xml on the other server, but also a tag set to true.
    See snapshotting