November 2nd, 2007
AS3: Getting the path of the HTML hosting the SWF
I was trying to get the full path of the HTML that is hosting the SWF in ActionScript 3. I found this post by Abdul Qabiz detailing how to use ExternalInterface to call JS and return the location. In his post, Abdul also details how to get any of the query string variables as well.
Since I'm sure I'll use it again and don't want to hunt it down, I'm posting it here for myself and well as everyone else who may find it useful.
CODE:
-
import flash.external.ExternalInterface;
-
-
var t:TextField = new TextField();
-
t.autoSize = TextFieldAutoSize.LEFT;
-
var full:String = ExternalInterface.call("window.location.href.toString");
-
t.text = full;
-
addChild(t);

