宜昌本地软件开发与弱电工程服务商
项目咨询 · 快速响应
您当前的位置: > 博客2 > AS2与AS3技术

[AS3]as3检测flash的swf文件所属域名附源代码实例

2016-10-13 00:16:48 点击量:10 标签: 收藏本文

写了一个类,用于检测swf是否存在于我们希望的网站中。

提供两个方法:

detectUrl(allow_url:String, is_unload:Boolean):Boolean
detectUrl 接受两个参数,第一个字符串参数为要检测的域名,域名不要带“http://”,如果处于此域名中,返回true,否则返回false。第二个布尔参数为是否则在返回ture时载影片。

detectUrlInTxt(txt_url:String, is_unload:Boolean):Void
detectUrlInTxt 接受两个参数,第一个字符串参数为包含要检测域名的txt文本文件,如果处于此域名中,调用onResult处理器,并传入值true,否则传入 false。如果载入txt文件失败,传入值null。第二个参数作用同detectUrl。txt文件中域名定义的格式 为:&allowUrl=www.abc.com&

  1. class Domain extends String{ 
  2.     private var txtLV:LoadVars; 
  3.     private var isUnLoad:Boolean; 
  4.     public var onResult; 
  5.     function Domain(Void){}; 
  6.     public function detectUrl(allow_url:String, is_unload:Boolean):Boolean{ 
  7.         var theDomain = _root._url; 
  8.         if((theDomain.indexOf(allow_url) != -1) && (theDomain.indexOf("http://") == 0)){ 
  9.             return true; 
  10.         }else{ 
  11.             isUnLoad = is_unload
  12.             if(isUnLoad){ 
  13.                 _root.unloadMovie(); 
  14.             } 
  15.             return false; 
  16.         } 
  17.     } 
  18.     public function detectUrlInTxt(txt_url:String, is_unload:Boolean):Void{ 
  19.         var owner = this
  20.         owner.isUnLoad = is_unload
  21.         txtLV = new LoadVars(); 
  22.         txtLV.load(txt_url); 
  23.         txtLV.onLoad = function(success:Boolean){ 
  24.             if(success){ 
  25.                 owner.onResult(owner.detectUrl(this.allowUrl)); 
  26.             } else { 
  27.                 owner.onResult(null); 
  28.                 if(owner.isUnLoad){ 
  29.                     _root.unloadMovie(); 
  30.                 } 
  31.             } 
  32.         } 
  33.     } 
ABOUT US
宜昌农人网络科技有限公司

我们是一家提供综合软件外包与弱电工程服务的技术公司。

业务涵盖定制软件、管理系统、网站、小程序、APP、系统集成、网络布线、监控安防、门禁、机房建设及长期技术维护。

公司地址:湖北省宜昌市伍家岗区东站二路6号三峡(宜昌)大数据产业园海洋馆二楼A203室