title: Get the hostname with action script 2
body: <p>I am creating some campaign swf banners and I don't use action script very often so any help from the experts would be great thanks.</p>
  
  <p>I am supplying my banners on my website as resource downloads. And tutorials of how to embed the swf which has some javascript flashvars.</p>
  
  <p>These flash variable is then concatenated into a google campaign link to change the utm_source.</p>
  
  <p>This is my javascript...</p>
  
  <pre><code>&lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
      var flashvars = {};
      flashvars.campaignSource = window.location.hostname;
      var params = {};
      params.loop = "true";
      params.quality = "best";
      params.wmode = "opaque";
      params.swliveconnect = "true";
      params.allowscriptaccess = "always";
      var attributes = {};
      swfobject.embedSWF("banner.swf", "banner_mpu", "300", "250", "9.0.0", false, flashvars, params, attributes);
  &lt;/script&gt;
  </code></pre>
  
  <p>and my html...</p>
  
  <pre><code>&lt;div id="banner_mpu"&gt;
      &lt;a href="http://www.adobe.com/go/getflashplayer"&gt;
      &lt;img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /&gt;
      &lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>So the above js works great, however, not everyone will use my tutorial code and will probably use there own methods to embed the swf banner on their site.</p>
  
  <p>So I need some back up action script 2 to get the current hostname into a action script variable</p>
  
  <p>This is my action script which I have so far on my button (swf)...</p>
  
  <pre><code>on(release) {
  
      function GetTheHostname() {
  
          var RootFullUrl = _root._url;
          txtFullUrl.text = RootFullUrl;
          var lastSlashIndex:Number = RootFullUrl.lastIndexOf("/");
          var DriveIndex:Number = RootFullUrl.indexOf("|");
  
          if (DriveIndex&gt;=0) {
          baseUrl = RootFullUrl.substring(0, DriveIndex);
          baseUrl += ":";
  
      } else {
  
          baseUrl = "";
  
      }
  
          baseUrl += RootFullUrl.substring(DriveIndex+1, lastSlashIndex+1);
          txtBaseUrl.text = baseUrl;
          return baseUrl;
  
      }
  
      var campaignSourceAS2:String= GetTheHostname();
  
      if ( _root.campaignSource == undefined ) {
  
          getURL("http://www.mysite.co.uk/?utm_source=" + campaignSourceAS2 + "&amp;utm_medium=MPU&amp;utm_campaign=My%20Campaign%202012", "_blank");
  
      } else {
  
          getURL("http://www.mysite.co.uk/?utm_source=" + _root.campaignSource + "&amp;utm_medium=MPU&amp;utm_campaign=My%20Campaign%202012", "_blank");
  
      }
  
  }
  </code></pre>
  
  <p>The problem with my action script is that it returns the full current URL.</p>
  
  <p>Can any one please help me adapt the GetTheHostname function to get the host name instead of the baseURL</p>
  
  <p><br /></p>
  
  <p>Thanks in advance</p>