netstrem获取302后的地址,可用来截图,加载实际跨域文件

直接放代码,老外博客看来的,老外还是牛逼,这都用出来了:http://jessewarden.com/2009/03/handling-crossdomainxml-and-302-redirects-using-netstream.html

 

try
{
var bit:BitmapData = new BitmapData(progressiveVideoPlayer.measuredWidth, progressiveVideoPlayer.measuredHeight, false, 0x000000);
bit.draw(progressiveVideoPlayer);
}
catch(error:SecurityError)
{
var list:Array = error.toString().split(" ");
var swfURL:String = list[7] as String;
var domain:String = list[10] as String;
domain = domain.substring(0, domain.length - 1);
var domainList:Array = domain.split("/");
var protocol:String = domainList[0] as String;
var address:String = domainList[2];
var policyFileURL:String = protocol + "//" + address + "/crossdomain.xml";
Security.loadPolicyFile(policyFileURL);
}

 -------------------------------- 2017/04/19更新---------------------------------------------

后来发现此方法没有通用性,只有debug版flash player能拿到详细错误信息,所以在用户那里还是无效,更通用的办法见我的下一篇博文。

posted @ 2016-10-18 15:46  sky0014  阅读(429)  评论(0编辑  收藏  举报