Friday, December 18, 2009

Setting security property checkPolicyFile for VideoDisplay component of Flex

SecurityError: Error #2122: Security sandbox violation: BitmapData.draw:

http://localhost:8080/Video.swf cannot access

http://www.helpexamples.com/flash/video/caption_video.flv. A policy file is required, but the checkPolicyFile flag was not set when this media was loaded. at flash.display::BitmapData/draw()

If you get above error what does that mean is Flash sandbox doesn't allow you to access resource from another server. If you put the video source file (FLV) on localhost or from server where application is loaded you are good.

To avoid this problem add following line into creationComplete() function or somewhere in your code before you access resource from third party server.

===================
Security.loadPolicyFile("http://www.websitename.com/crossdomain.xml");
===================

Above scenario is applicable to VideoDisplay of Flex because it doesn't come with checkPolicyFile property. But Image component has such property, which make it easy.

One thing like so much about flash/flex is active community with many informative blog post.

No comments: