Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8579677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:39:36+00:00 2026-06-11T20:39:36+00:00

I am creating some campaign swf banners and I don’t use action script very

  • 0

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.

I am supplying my banners on my website as resource downloads. And tutorials of how to embed the swf which has some javascript flashvars.

These flash variable is then concatenated into a google campaign link to change the utm_source.

This is my javascript…

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
<script type="text/javascript">
    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);
</script>

and my html…

<div id="banner_mpu">
    <a href="http://www.adobe.com/go/getflashplayer">
    <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
    </a>
</div>

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.

So I need some back up action script 2 to get the current hostname into a action script variable

This is my action script which I have so far on my button (swf)…

on(release) {

    function GetTheHostname() {

        var RootFullUrl = _root._url;
        txtFullUrl.text = RootFullUrl;
        var lastSlashIndex:Number = RootFullUrl.lastIndexOf("/");
        var DriveIndex:Number = RootFullUrl.indexOf("|");

        if (DriveIndex>=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 + "&utm_medium=MPU&utm_campaign=My%20Campaign%202012", "_blank");

    } else {

        getURL("http://www.mysite.co.uk/?utm_source=" + _root.campaignSource + "&utm_medium=MPU&utm_campaign=My%20Campaign%202012", "_blank");

    }

}

The problem with my action script is that it returns the full current URL.

Can any one please help me adapt the GetTheHostname function to get the host name instead of the baseURL

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T20:39:38+00:00Added an answer on June 11, 2026 at 8:39 pm

    In that case, I guess it would be as easy as stripping the http:// from the url and then get all that’s left to the first /

    A one-liner to go from ‘http://www.example.com/category/actionscript’ to ‘www.example.com’ would be

    var baseURL:String = _root._url.split("http://").join("").split("/")[0];
    

    and to replace your full method

    getURL("http://www.mysite.co.uk/?utm_source=" + (_root.campaignSource || _root._url.split("http://").join("").split("/")[0]) + "&utm_medium=MPU&utm_campaign=My%20Campaign%202012", "_blank");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating some action script to simulate 3 button states and load in
after creating some menus with simple_list_item_1 (which worked very fine) I tried to replace
I'm creating some tests with JMeter, the situation is very simple, I have a
I'm currently creating some sliders in Javascript, for use with touch, and the results
I'm creating some custom views for the Django admin interface that use the standard
Creating some simple html pages specific for the iphone, and would like to use
I'm creating some videos from a collection of images, I subsequently wish to play
I am creating some html from code running on a WinForm. I want to
I'm creating some maps from raster files using the raster package in R. I'd
I creating some code for showing box with diffrent heights (height will be from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.