ActionScript - How to get the current URL with Flash Actionscript
January 14th 2010
How do you get the current URL of a Flash page in Flash?
The question of how to get the current URL of a Flash movie has come my way a couple of times, so I thought I would post just how to do that. I have found a way that is simpler than most of the examples I have seen on the subject.
You're working on the next coolest Flash application to hit the web and you have a need to find out what the current URL is. But how do you do that? Does Flash have a way to access this information?
The first thing we need to do is include the Flash external library. To do this we will use the import command. On the first frame of your Flash file add this line of Actionscript:
This line tells Flash to include the external library which contains a function we will need to complete our task.
var currentURL:String = String(ExternalInterface.call("window.location.href.toString"));
We now have a variable with the current URL.
Hope this helps.
Web Department Manager