Keun Lee

Developer Journal

20070123 Tuesday January 23, 2007

Flex 2 VideoDisplay + Security sandbox violation : BitmapData.draw on RTMP

If you ever tried to do a bitmapdata.draw from an RTMP source, you might’ve gotten the following security Error:

SecurityError: Error #2135: Security sandbox violation: BitmapData.draw: _ cannot access _. RTMP content cannot be accessed using this API.

Last month, Chris Chen posted a snippet on how to get by this error found here. To recap on the solution to the issue, the idea is to detach your netstream before doing your draw method, then to reattach it afterwards. Chris’s method works well for a Video Class coming from the flash.media.* namespace.

However, if you try this with a Flex VideoDisplay component, there is no available way of getting access to the underlying Video Class… or so we thought. Since the videoDisplay component is open source within the Flex 2 source tree, I figure, why not take a peek to see where that Video Class is at. Sure enough, there were several other ( excluded ) classes, in relation to the VideoDisplay component found in ( source/mx/controls/videoClasses ). So, what I needed at this point was a reference to the underlying video and netstream, in which I went ahead and made a modified copy of the default Flex VideoDisplay component along with it’s relevant dependent classes… you can pick those up here.

… and so, now we’re able to do the following with a VideoDisplay component:

video.videoPlayer.attachNetStream( null );
var data:BitmapData = new BitmapData(…);
data.draw( video.videoPlayer );
video.videoPlayer.attachNetStream( video.videoPlayer.ns );



<controls:VideoDisplay id=“video” source=“videos/video.flv” width=“400″ height=“400″/>

Posted by keunlee | Jan 23 2007, 01:00:13 PM EST
XML