在ActionScript 3的相对URL [英] Relative URLs in Actionscript 3

查看:121
本文介绍了在ActionScript 3的相对URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用ActionScript 3的一些按钮,打开链接到新的网页Flash影片。这里是code我有一个重定向到新的页面:

I have a flash movie using Actionscript 3 with some buttons that open links to new pages. Here is the code I have for redirecting to the new page:

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

它工作正常,我的生产服务器上使用完整的URL包括域名,但是当我将其更改为这样的:

It works fine on my production server with the full url including domain, but when I change it to this:

var request:URLRequest = new URLRequest('page2.html');

它不再生产工作。我在想什么吗?我想不必EN code整个URL到影片中。

it no longer works in production. What am I missing here? I would like to not have to encode the entire URL into the movie.

推荐答案

URLRequests是相对于HTML文件,其中包含它们(也没关系,你的SWF是),所以你需要考虑到这一点。 还有就是嵌入/对象,你可以设置为改变这种行为的一个可选属性,在这里看到:

URLRequests are relative to the HTML file containing them (it doesn't matter where your SWF is), so you need to take that into account. There is an optional attribute of the EMBED/OBJECT that you can set to change this behaviour, see here:

基础 - 。或[基本目录]或[URL]。指定基本目录或   URL用于解析所有的相对路径   声明在Flash Player影片。   此属性是有用的,当你   Flash播放电影都保存在一个   从您的其他不同的目录   文件。

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.

<一个href="http://kb2.adobe.com/cps/127/tn%5F12701.html">http://kb2.adobe.com/cps/127/tn_12701.html

编辑: 另外,尽量避免使用绝对URL相对文件,你可以得到沙盒的错误,例如,加载网页没有WWW。

Also, try to avoid using absolute URLs for relative files, as you could get sandbox errors, for instance, loading the web without "www."...

这篇关于在ActionScript 3的相对URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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