Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can my Flash app determine its own URL?

My flash app needs to know its own URL, so that it can load some (non-embedded) content using relative paths.

(I cannot hardcode the full paths because there will be multiple installs -- staging, production, etc. Nor can I use simple relative paths because there's one legacy install that uses a different relative path (ugh). And I cannot just embed the content, because it is shared. I need to get the full URL and then do some if statements with it.)

(Please note that the URL of the page into which the .SWF file is embedded will not work. The app is included in a CMS, so the page URLs can be quite different from the content URLs. I need the actual URL of the .SWF file.)

Can this be done programatically, or am I stuck with passing the URL as a parameter?

like image 949
Eric Avatar asked Dec 28 '08 17:12

Eric


2 Answers

In AS3, the URL of current swf file can be found via the LoaderInfo class instance. So in your main document class (or main stage frame script) this should give your the URL of your swf file:

this.loaderInfo.url

Every MovieClip has a loaderInfo member, that will give you its info.

LoaderInfo livedocs.

like image 142
tehnomaag Avatar answered Oct 03 '22 19:10

tehnomaag


mx.managers.BrowserManager

Adobe Flex LiveDocs

Accessing information about the current URL

like image 33
gregjor Avatar answered Oct 03 '22 19:10

gregjor