flash - Actionscript 3 中的相对 URL

标签 flash actionscript-3

我有一个使用 Actionscript 3 的 Flash 电影,其中有一些按钮可以打开指向新页面的链接。这是我重定向到新页面的代码:

myButton.addEventListener(MouseEvent.CLICK, function(e:MounseEvent) {
    var request:URLRequest = new URLRequest('http://www.example.com/page2.html');
    navigateToURL(request, "_top");
});

它在包含域的完整 url 的生产服务器上运行良好,但是当我将其更改为:
var request:URLRequest = new URLRequest('page2.html');

它不再适用于生产。我在这里错过了什么?我不想将整个 URL 编码到电影中。

最佳答案

URLRequests 与包含它们的 HTML 文件相关(您的 SWF 在哪里并不重要),因此您需要考虑到这一点。
您可以设置 EMBED/OBJECT 的一个可选属性来更改此行为,请参见此处:

base - . or [base directory] or [URL]. Specifies the base directory or URL used to resolve all relative path statements in the Flash Player movie. This attribute is helpful when your Flash Player movies are kept in a different directory from your other files.



http://kb2.adobe.com/cps/127/tn_12701.html

编辑:
此外,尽量避免对相对文件使用绝对 URL,因为您可能会遇到沙箱错误,例如,在没有“www”的情况下加载 Web。...

关于flash - Actionscript 3 中的相对 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1575771/

相关文章:

flash - (Flash CS5.5) 基本 Away3D 设置帮助

sqlite - 将数组传输到 SQLite 中,反之亦然,无需循环,尤其是在 ActionScript3 中

Java LocalConnection 客户端

flash - ActionScript 2,嵌套影片剪辑列表

actionscript-3 - 如何组织复杂的 Flash 项目

apache-flex - Adobe Flex .swf 缓存

actionscript-3 - Flash CS6错误1120 : Access of undefined property (AS3)

jquery - 网站上的信息图和图表

macos - 适用于 Mac 的免费 ActionScript IDE?

actionscript-3 - AS3中的void和void有什么区别?