Created
January 13, 2012 18:01
-
-
Save blt04/1607809 to your computer and use it in GitHub Desktop.
Security.allowDomain sub-domain support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Allow thinkwell.com and thinkwell.com subdomains | |
// The current domain is automatically added. The AllowDomain flash | |
// var can be used to add an additional domain. | |
private function setAllowDomains():void{ | |
// Only apply allowdomain security settings to thinkwell.com and subdomains | |
var pattern:RegExp = /^(.*\.)?thinkwell\.com$/ | |
var allowDomains:Array = new Array(); | |
// Try to add the current domain | |
try { | |
var url:String = ExternalInterface.call("window.location.href.toString"); | |
var host:String = URLUtil.getServerName(url); | |
if (host && pattern.test(host)) { | |
allowDomains.push(host); | |
} | |
} catch(e:Error) {} | |
// If the the AllowDomain flash var exists, add it to the allowedDomains | |
// list as well | |
if (parameters['AllowDomain'] && pattern.test(parameters['AllowDomain'])) { | |
allowDomains.push(parameters['AllowDomain']); | |
} | |
if (allowDomains.length > 0) { | |
Security.allowDomain.apply(Security, allowDomains); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment