Community

To:
Subject:
Message:
or Cancel

Filtering other ads.

Jol
Aug 07, 2007 (6 years 256 days ago)

United States US
I have a non-exclusive sponsorship deal going down with a site that doesn't want the mochiAds to show on their site, just their logo. The problem: It is a non-exclusive deal which means that their ad is only supposed to show on their site. I can disable the MochiAds on their site, but I don't know how to filter out their site's ad from all of the sites they pass it on to.

Can anyone link me to a tutorial or give me some advice on this? I could probably figure it out if I knew which command to use to detect the URL that the game is being played on.

I'm teaching myself out of a book, and it has no information on how to do this. Any help is appreciated.
  • Thankful People:

Filtering other ads.

bob
Aug 07, 2007 (6 years 256 days ago)

United States US
You want to use the _url of the main MovieClip (probably _root), and then take a look to see what the domain name is.

Maybe something like this:

function url_in_domain(url, domain) {
url = url.toLowerCase();
domain = domain.toLowerCase();
if (url.substr(0, 7) != "http://") {
return false;
}
var domainParts = domain.split(".");
var urlDomainParts = url.substr(7).split("/")[0].split(".");
while (domainParts.length > 0) {
if (domainParts.pop() !== urlDomainParts.pop()) {
return false;
}
}
return true;
}
  • Thankful People:

Filtering other ads.

Jol
Aug 07, 2007 (6 years 256 days ago)

United States US
Wow, you guys do just about everything except my dishes!

Thanks!
  • Thankful People:

Filtering other ads.

Jol
Aug 07, 2007 (6 years 256 days ago)

United States US
I ran into a problem. When I try to trace url, it turns up undefined.
This is the system I'm using.

if (url.substr(0, 7) != "http://"){
trace1 = "http false";
trace3 = url.substr(0, 7);
}

if(url.substr(8, 16) != "adventuresofjoel"){
trace2 = "middle false";
trace4 = url.substr(8, 16);
}


The problem is, it turns up like this:
trace1 = http false
trace2 = middle false
trace3 = undefined
trace4 = undefined

Why wont it return the URL? I even uploaded it to a remote location to test and it still didn't work.
  • Thankful People:

Filtering other ads.

bob
Aug 07, 2007 (6 years 256 days ago)

United States US
The function I demonstrated just checks a URL against a domain. You would want to call it like:

if (url_in_domain(_root._url, "example.com")) {
...
}
  • Thankful People:

Filtering other ads.

Jol
Aug 08, 2007 (6 years 255 days ago)

United States US
YES! I know what I was doing wrong!!! I was not putting and underscore before the "url." I had it like this: _root.url
When it should have been _root._url.

THANK YOU SO MUCH!
  • Thankful People:
Back To The Forums