I have a swf on my website with some links.
The problem is that i have many subdomains.
ex. es.domain.com, it.domain.com
I'm using a delivery network so the same swf file is served on every subdomain.
My buttons have a simple call
Is there a way to replace the www with the current subdomain ?
If you're just trying to load an URL however (as in navigate the whole current page to a different URL of any kind what-so-ever) you can do that without any cross domain. Subdomains can only cause issues if you try to load assets from them inside a SWF on a different domain, forcing you to include some cross domain policy.
Here's an explaination of crossdomain.xml and cross domain policy:
Exactly what error/issue happens?
Thank you for your reply.
I don't get any errors, it's just redirecting me in the www page.
For example, if i am on sub.domain.com and click a link in my swf (domain.com/items/web) it will redirect me to www.domain.com/items/web and not stay to sub.domain.com/items/web.
Sorry if i'm not very clear but i can't explain it better and i'm not an expert in Flash.
I read the article for cross domain policy but i'm not exactly sure what i'm supposed to do except the crossdomain.xml file.
Should i change the links inside swf ?
Are these swfs served FROM different subdomains or pages load THE SAME swf from the same location and pages themselves are loaded from different subdomains?
If former - read SWF location in LoaderInfo.url
Read browser location:
Then use values in navigateToURL
www is the default if you are not excplicitly setting the location otherwise. If you want to stay on sub.domain.com then you need to either use relative URLs (e.g. URLRequest('/images/some.jpg')) or specify the full URL (e.g. URLRequest('http://sub.domain.com/images/some.jpg);). Even standard HTML links (e.g. <a href="domain.com/items/web">click me</a>) will fail to stay on a sub.domain.com URL. You'd need to supply it (e.g. <a href="http://sub.domain.com/items/web">click me</a>).
Hello Andrei1 and sinious,
Thank you for your reply.
The swf that is served is the same for every subdomain, so i can't use the full URL to my links.
If i use relative URLs i have another problem.
e.g. If i am on sub.domain.com/items and my link is relative (items/web) it will load sub.domain.com/items/items/web and not sub.domain.com/items/web.
I have stuck on this and i can't find a solution as simple as it may seem.
If someone can give me advice, i can send pm with links to the site so you can understand better, i would really appreciate any help on this.
In your example you want the "/items/web" folder and you're already inside "/items" so you wouldn't write "/items/web", you'd just write "web/".
The root of a SWF is the HTML that's hosting the file so all relative linking should be from the HTML and not the SWF location incase that's tripping you up. I assume you're using some type of MVC where sub.domain.com/index.php|aspx is loading the /items controller with the argument /web. If that's the case then the SWF root would actually really be root. If you literally have HTML loading the SWF inside the /items folder (e.g. /items/somefile.html|aspx|php) then your root is already "/items" and you should not re-supply it in requests or yes, you'll get "/items/items/web".
You can PM me a link if you like.