·您当前的位置:首页 > 技术教程 > AS2与AS3技术 >

[AS3]as3获取一个字符串地址中的域名

时间:2014-04-17 09:44cuplayer.com
[AS3]as3获取一个字符串地址中的域名

AS3]as3获取一个字符串地址中的域名

  1. public function fetchDomainRootURL() : String 
  2. { 
  3.     var domainRootURL : String  = null; 
  4.     // if pure as3 project, fetch complete URL just remove 'parent' 
  5.     var completeURL : String    = this.parent.stage.loaderInfo.url; 
  6.     trace(completeURL); 
  7.     // cuplayer.com: step 1 : start with 'http' 
  8.     var httpIdx : int   = completeURL.indexOf('http'); 
  9.     trace(httpIdx); 
  10.     if (httpIdx == 0) 
  11.     { 
  12.         // cuplayer.com: step 2 : the first index of '//' 
  13.         var doubleSlashsIdx : int   = completeURL.indexOf('//'); 
  14.         trace(doubleSlashsIdx); 
  15.         if (doubleSlashsIdx != -1) 
  16.         { 
  17.             // cuplayer.com:step 3 : the first index of '/' 
  18.             var domainRootSlashIdx : int    = completeURL.indexOf('/', doubleSlashsIdx + 2); 
  19.             trace(domainRootSlashIdx); 
  20.             if (domainRootSlashIdx != -1) 
  21.                 domainRootURL   = completeURL.substring(httpIdx, domainRootSlashIdx + 1); 
  22.         } 
  23.     } 
  24.     trace(domainRootURL); 
  25.     return domainRootURL; 
  26. } 

 

热门文章推荐

请稍候...

保利威视云平台-轻松实现点播直播视频应用

酷播云数据统计分析跨平台播放器