Skip to content

Instantly share code, notes, and snippets.

@MattMcFarland
Created May 10, 2011 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MattMcFarland/964617 to your computer and use it in GitHub Desktop.
Save MattMcFarland/964617 to your computer and use it in GitHub Desktop.
if (checkDomain(["flashgamelicense.com"]))
public function checkDomain (allowed:*):Boolean
{
var url:String = FP.stage.loaderInfo.url;
var startCheck:int = url.indexOf('://' ) + 3;
trace (url);
//if (url.substr(0, startCheck) == 'file://') return true;
var domainLen:int = url.indexOf('/', startCheck) - startCheck;
var host:String = url.substr(startCheck, domainLen);
if (allowed is String) allowed = [allowed];
for each (var d:String in allowed)
{
if (host.substr(-d.length, d.length) == d) return true;
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment