Application.application.url in Flash AS3

Posted on October 16, 2008 | Comments Off

The solution to accessing the loader information url property is quite easy in Flash ActionScript 3. But when you Google for the solution its not obvious. Hence I am creating a post about it.

In Flex you can access the url of the SWF by accessing Application.application.url. What this value represents is the root.loaderInfo.url property. So in Flash and AS3 you would do this:

var tf:TextField = new TextField();
tf.autoSize = TextFieldAutoSize.LEFT;
tf.border = true;

tf.appendText("params:" + "\n");
try {
    var keyStr:String;
    var valueStr:String;
    tf.appendText(LoaderInfo(this.root.loaderInfo).url + "\n");
    var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
    for (keyStr in paramObj) {
        valueStr = String(paramObj[keyStr]);
        tf.appendText("\t" + keyStr + ":\t" + valueStr + "\n");
} catch (error:Error) {

The important part is accessing the root’s loaderInfo object. The above code also shows how to access the FlashVar parameters in ActionScript 3.

Example code referenced from here.