16 Replies Latest reply on Dec 30, 2013 10:24 PM by NightostJ

    i used netStream.appendBytes() ,but can not call bitmapData.draw()


      the tips: Error #2123: Security sandbox violation: BitmapData.draw: cannot access null. No policy files granted access.


      Here is some sample code


      import flash.display.Sprite;
      import flash.filesystem.File;
      import flash.filesystem.FileMode;
      import flash.filesystem.FileStream;
      import flash.media.Video;
      import flash.net.NetConnection;
      import flash.net.NetStream;
      import flash.net.NetStreamAppendBytesAction;
      import flash.utils.ByteArray;
      import flash.display.BitmapData;

      class ByteArrayPlayer extends Sprite
      private var _ns:NetStream;
      private var _nc:NetConnection;
      private var _video:Video;

      public function playVideo(path:String):void
      = new NetConnection();
      = new NetStream(_nc);

                  _ns.checkPolicyFile = true;

      = new Video();


      var file:File = new File(path);
      var fileStream:FileStream = new FileStream();
      .open(file, FileMode.READ);

      var bytes:ByteArray = new ByteArray();



      public function getImage(video:Video):BitmapData
      var bit:BitmapData = new BitmapData(_video.width, _video.height);
      .draw(_video);            //This will cause the error
      return bit;


      This is only sample code use for an explanation. The error would happen when calling the getImage method while the video is playing.

      The error mentions a policy file not found. Since the file is loaded locally there isn't really a place to put a policy file.

      Is there a policy setting somewhere that needs to be set or is the BitmapData.draw feature just not available when using appendBytes?

      It is a local flv file,  not an ramp stream from a server.