• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

New Here ,
Nov 14, 2011 Nov 14, 2011

Copy link to clipboard

Copied

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

Here is some sample code

package
{
   
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
       
{
            _nc
= new NetConnection();
            _nc
.connect(null);
            _ns
= new NetStream(_nc);

            _ns.checkPolicyFile = true;

            _video
= new Video();
            addChild
(_video);
            _video
.attachNetStream(_ns);

            _ns
.play(null);
            _ns
.appendBytesAction(NetStreamAppendBytesAction.RESET_BEGIN);

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

           
var bytes:ByteArray = new ByteArray();

            fileStream
.readBytes(bytes);

            _ns
.appendBytes(bytes);
       
}


       
public function getImage(video:Video😞BitmapData
       
{
           
var bit:BitmapData = new BitmapData(_video.width, _video.height);
            bit
.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.


TOPICS
ActionScript

Views

6.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 14, 2011 Nov 14, 2011

Copy link to clipboard

Copied

you need to add policy files to the server that's sending your data.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 14, 2011 Nov 14, 2011

Copy link to clipboard

Copied

But i load the local flv file from my computer,  not an ramp stream from a server. it is nowhere to load the policy file

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 15, 2011 Nov 15, 2011

Copy link to clipboard

Copied

you're still crossing a security sandbox.  to remedy a local security sandbox issue, adjust your fp settings:  http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 15, 2011 Nov 15, 2011

Copy link to clipboard

Copied

i was set that, but it still caused the same error

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 17, 2011 Nov 17, 2011

Copy link to clipboard

Copied

Can someone help me?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 18, 2011 Nov 18, 2011

Copy link to clipboard

Copied

I can't offer a solution other than to use _ns.play(path); instead - then you should not get the error. AIR should not throw security errors so may be you can log this as a bug at Adobe?

--

Kenneth Kawamoto

http://www.materiaprima.co.uk/

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 18, 2011 Nov 18, 2011

Copy link to clipboard

Copied

you can get security errors with air, even with local content, if you're manipulating content outside certain (i can't remember which but i think anything outside the apps own directory is ok) directories.

try adding:

Security.allowDomain(*);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 18, 2011 Nov 18, 2011

Copy link to clipboard

Copied

try adding:

Security.allowDomain(*);

That will not work in AIR.

Also, if you use NetStream.play(path) you will not get the security error, therefore it's nothing to do with the file being outside of application sandbox.

--

Kenneth Kawamoto

http://www.materiaprima.co.uk/

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 28, 2011 Nov 28, 2011

Copy link to clipboard

Copied

Does this actually stream to a Flash Media Server or similar? If so, can you just skip the draw function for now? I assume you're using it as a preview monitor window. Can you see the video through server?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 27, 2012 May 27, 2012

Copy link to clipboard

Copied

Have you found a solution to this problem?  I ran into the same situation but couldn't find a solution anywhere.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 28, 2012 May 28, 2012

Copy link to clipboard

Copied

If you want to capture a video with BitmapData.draw() you can do so without any issues if you do not use ByteArray. Do you have a specific reason to use ByteArray?

--

Kenneth Kawamoto

http://www.materiaprima.co.uk/

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 22, 2013 Feb 22, 2013

Copy link to clipboard

Copied

even time past and flashplayer upgraded,old problem is still old one.

the thing i wanna to do is a open a local video file into my swf app,then play this video,meanwhile,capture the current video frame.

my code is similar with lanphonexm

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 09, 2013 Dec 09, 2013

Copy link to clipboard

Copied

Hi,have you get something about this?

I'm running into the same issue.

I just use _netstream.play(null),  and then do appendBytes.

The problem is that I can't use


bit.draw(_video);

email:nightost@yeah.net


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 13, 2013 Dec 13, 2013

Copy link to clipboard

Copied

I'm suffering for same issue. I guess it is a bug of NetStream class!!

Please email me who solved it and got workaround.

soccerjung@naver.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 29, 2013 Dec 29, 2013

Copy link to clipboard

Copied

Hey- if you still have issues on flash runtime ,would you pls log a bug to

https://bugbase.adobe.com/, thanks.

While adding the bug, please include sample code and the exactly browser(version) you used so we can quickly test this out internally.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 30, 2013 Dec 30, 2013

Copy link to clipboard

Copied

LATEST

The same problem with this:

http://forums.adobe.com/message/5919873

Bug report:

https://bugbase.adobe.com/index.cfm?event=bug&id=3617751

Deal with this asap.

Thanks a lot !

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines