Flash作品的播放保护

如果实现swf文件不能在本地或者非法url中播放,就可以达到一定程度的保护效果。下面来讲一下实现的大致思路,

代码如下:

var this_url = _root._url; if (substring(this_url,1,4) == 'file'){ //如果在硬盘上播放,作出处理 trace('对不起,禁止在本地播放!'); }else{ //表示在网页中播放,则检查是否是合法的URL地址 urlArray = this_url.split("/"); //对url地址分割 if (urlArray[2]!='yourweb.com'){ getURL("javascript:alert('访问被禁止!')"); }else { getURL("javascript:alert('欢迎光临YourName!')"); } }

注意:该段代码必须写在开头,具体的处理控制还需要细化才行。

因为客户端的安全性不并是很好,所以建议在服务器端作保护控制,下面的方法采用了服务器端的实现:

` //访问保护
application.onAppStart = function (info){
this.domainList = new Array("http://210.64.45.41";,"http://210.64.45.38";,"http://vid
eo.idv.to";);
this.domainLength = this.domainList.length;
};

application.onConnect = function(client_obj) {
//限制访问
trace("user trying to connect from:" + client_obj.referrer);
var theReferrer = client_obj.referrer.toLowerCase();

for(i=0; i var challenge = theReferrer.indexOf(this.domainList[ i ]);
if (challenge == 0) {
acceptit = 1;
break;
}
}
if (acceptit) {
trace ("correct domain, accepting connection");
application.acceptConnection(client_obj)
} else {
trace ("Sorry wrong domain, rejecting connection");
application.rejectConnection(client_obj)
}
}

`

Published At
Categories with 图形图象
Tagged with
comments powered by Disqus