我的 Flash 应用程序如何确定自己的 URL? [英] How can my Flash app determine its own URL?

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

问题描述

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

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

(我不能硬编码完整路径,因为会有多个安装——暂存、生产等.我也不能使用简单的相对路径,因为有一个遗留安装使用不同的相对路径(呃).我不能只是嵌入内容,因为它是共享的.我需要获取完整的 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 文件的 URL:

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

每个 MovieClip 都有一个 loaderInfo 成员,它会给你它的信息.

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

LoaderInfo livedocs.

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

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