What does a Flash object know about the page in which it is located?

advertisements

The organization I work for has created a small flash widget that we're encouraging supporters to place on their website. I'm trying to determine if there are ways to improve the statistics we get from those embedded widgets.

Mostly I would like to get the domain of the site that loaded the widget. Right now I'm able to see the referrer in the server logs, but that includes the full URL, and I don't want to have to write my own log processing system just to pull out domains.

I know very little ActionScript, but I've looked around the ActionScript documentation to see if I could find an obvious solution. I haven't found anything that allows the object to ask the browser for the page URL. The System.Capabilities class seems to provide a lot of information about the player's environment, but not where the player was called from (as far as I can tell, but maybe I'm missing something).


Steps:
   1. Import external interface into your file: import flash.external.ExternalInterface;
   2. Initialize a variable to store the url path: var urlPath;
   3. Create a function to call external interface and assign the html page path to your variable: urlPath = ExternalInterface.call(”window.location.href.toString”);
   4. Call the function when/if needed.

Example:

With javascript: window.location.href or window.location.href.toString(); With actionscript: ExternalInterface.call(”window.location.href.toString”); External Interface html Example

Source: http://blog.circlecube.com/2008/01/02/get-current-url-to-flash-swf-using-an-external-interface-call/

To Get The Query String See This Article: http://blog.circlecube.com/2008/03/20/get-current-url-and-query-string-parameters-to-flash-tutorial/