How to Get the Current Page's URL into Flash
This little trick allows a Flash movie (swf) to find out the URL of the page in which it's embedded. After wondering about this for some time, I finally found a blog post with the solution. Here's the key bit of code:
import flash.external.ExternalInterface; var pageURL:String = ExternalInterface.call('window.location.href.toString');
This could be useful if you're using the query string in the URL to keep track of the application's state. However, the solution comes with one caveat: Javascript must be enabled for this to work. The Actionscript 3.0 documentation says that if the window.location.href.toString method doesn't return a value then ExternalInterface.call will return null. Same thing happens when Javascript is disabled.
Here's the original blog post by Abdul Qabiz: How to get URL query-string variables within Flex application
Delicious
Digg
Reddit
Facebook
Google
Yahoo
Technorati

Comments
Is it possible to load a URL into a flash movie without leaving flash? reason is that I like to use the flash fullscreen to have a real fullscreen for my htm website.
Hi Alex,
I realize this is really late but maybe somebody can still benefit from this answer. Flash does a terrible job of rendering entire HTML pages so I definitely wouldn't recommend trying to display a page right in Flash. Unfortunately your best bet is going to be implementing all your content in Flash.
Hope that helps.
Thanks for your answer.
Post new comment