我有一个使用 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/