Reputation: 2663
I have SWF hosted on a domain lets say www.aaa.com. I am embedding that swf in an html page which is on www.bbb.com. Now, within the SWF, how can I get the domain where SWF is being embedded i.e. in my example www.bbb.com?
I can do it via javascript and then pass the domain name to as3, but I want to do it from within the SWF due to certain requirements. Also, i don't want to load my SWF in another SWF which is on www.bbb.com.
Any answers...?
Upvotes: 0
Views: 153
Reputation: 341
Yes you can do this in any sprite:
//this will work in any pure AS3 class
var sp:Sprite = new Sprite;
trace(sp.loaderInfo.url);
If you are using Flex, then do this after the child is added to the stage/display list.
To get the domain, you can use regular expression to parse the url, or just look for the string between "http://" and "/".
Upvotes: 0
Reputation: 1985
you say you are embedding the flash on the bbb domain, so i guess you have access to the bbb's server page generator.
in that case i would just include the domain name in the flashVars, for example: topdomain=<?php echo(urlencode($_SERVER['SERVER_NAME'])); ?>
and then access the topdomain variable inside the swf. in case it's undefined, assume that it's embedded from somewhere else
Upvotes: 1