flash – Actionscript 3中的相对URL

我有一个使用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.”的网络…

相关文章

  译序:JWMediaPlayer是开源的网页使用的Flash播放器。本...
    Flash编程原理都是只能将1写为0,而不能将0写成1.所...
 上传setenvgatewayip192.168.1.1;setenvserverip192.168.1...
Error:FlashDownloadFailed-"Cortex-M3"出现一般有...
jPlayer是一个用于控制和播放mp3文件的jQuery插件。它在后台...
#ifndef__FONTUPD_H__#define__FONTUPD_H__#include"sy...