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

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

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

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

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

 

ABOUT US
宜昌农人网络科技有限公司

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

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

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