如何让我的Flash应用程序决定自己的网址是什么? [英] How can my Flash app determine its own URL?

查看:94
本文介绍了如何让我的Flash应用程序决定自己的网址是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Flash应用程序需要知道它自己的网址,以便它可以加载使用相对路径的一些(非嵌入)的内容。

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

(我不能硬code的完整路径,因为将有多个安装 - 运行,生产,等我也不能用简单的相对路径,因为有一个传统的安装使用不同的相对路径(啊)。我不能只是嵌入的内容,因为它是共享的。我需要得到完整的URL,然后做一些if语句吧。)

(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.)

(请注意,到其中的.SWF文件嵌入将无法工作页面的URL。这个应用程序包含在一个CMS,所以页面的URL可以是从内容的URL完全不同的。我需要实际的URL .swf文件的。)

(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.)

可以这样做编程,还是我坚持传递URL作为参数?

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

推荐答案

在AS3中,可以通过LoaderInfo类实例,发现当前SWF文件的URL。因此,在主文档类(或主舞台框架脚本),这应该给你的SWF文件的您的网址:

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

this.loaderInfo.url

每一个影片剪辑都有一个LoaderInfo成员,会给你的信息。

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

<一个href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/LoaderInfo.html#url">LoaderInfo LiveDocs中。

这篇关于如何让我的Flash应用程序决定自己的网址是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆