AS3使用加载器加载一个文件htaccess的保护 [英] AS3 Using a Loader to load a file protected by htaccess

查看:188
本文介绍了AS3使用加载器加载一个文件htaccess的保护的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图加载的托管在一个网站到本地的SWF文件外部SWF。外部SWF是在一个密码保护的目录使用htaccess的。

I'm attempting to load an external SWF that's hosted on a site into a local SWF file. The external SWF is in a password-protected directory using htaccess.

下面是code我目前正在使用的:

Here is the code I'm currently trying to use:

var loaderUrlRequest:URLRequest = new URLRequest("http://www.my-website.com/externalFlashFile.swf");
loaderUrlRequest.requestHeaders.push(new URLRequestHeader("Authorization", "Basic " + $Base64.encode("username:password")));
loaderUrlRequest.method = URLRequestMethod.POST;
loaderUrlRequest.data = true;
var loader:Loader = new Loader();
addChildAt(loader, 0);
loader.load(loaderUrlRequest);

该文件的URL,用户名,密码和base64编码都被检查和正确的。

The file URL, username, password, and base64 encoding are all checked and correct.

不过,我收到以下错误:

However, I'm getting the following errors:

Error opening URL 'http://www.my-website.com/externalFlashFile.swf'
Error #2044: Unhandled IOErrorEvent:. text=Error #2036: Load Never Completed.

任何想法我可能是做错了,或者有更好的方法去了解这个从纯粹的闪光角度?

Any ideas what I might be doing wrong, or if there's a better way to go about this from a purely-flash perspective?

感谢。

推荐答案

<一个href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLRequestHeader.html"相对=nofollow>白鲸,圣杯

在使用Adobe®AIR®,在应用程序安全沙箱中的内容(如使用AIR应用程序安装的内容)可以使用任何请求标头,而不会出现错误。 然而,内容运行在Adobe AIR是在不同的安全沙箱或在Flash®Player将中运行的内容,使用以下请求头导致运行时错误

In Adobe® AIR®, content in the application security sandbox (such as content installed with the AIR application) can use any request headers, without error. However, for content running in Adobe AIR that is in a different security sandbox, or for content running in Flash® Player, using following request headers cause a runtime error:

接收字符集,接受编码,接受,范围,年龄,允许,允许,授权,荷,连接,连接,内容长度,内容,地点,内容范围,饼干,日期,删除,ETag的,期待,获取,头,主机,如果修改 - 因为,保持活动,最后修改,地理位置优越,马克斯 - 远期,期权,产地,邮政,代理服务器进行身份验证,代理授权,代理连接,公共,放,范围,引用站点,要求,范围,重发后,服务器,TE,跟踪,拖车,传输编码,升级,URI,用户代理,因人而异,威盛,警告,WWW身份验证,的X闪光版本。

Accept-Charset, Accept-Encoding, Accept-Ranges, Age, Allow, Allowed, Authorization, Charge-To, Connect, Connection, Content-Length, Content-Location, Content-Range, Cookie, Date, Delete, ETag, Expect, Get, Head, Host, If-Modified-Since, Keep-Alive, Last-Modified, Location, Max-Forwards, Options, Origin, Post, Proxy-Authenticate, Proxy-Authorization, Proxy-Connection, Public, Put, Range, Referer, Request-Range, Retry-After, Server, TE, Trace, Trailer, Transfer-Encoding, Upgrade, URI, User-Agent, Vary, Via, Warning, WWW-Authenticate, x-flash-version.

URLRequestDefaults.setLoginCredentialsForHost :设置默认的用户名和密码凭据为选定的主机。 ... 仅使用Adobe®AIR®在应用程序安全沙箱中运行的内容可以使用URLRequestDefaults类。

URLRequestDefaults.setLoginCredentialsForHost: Sets default user and password credentials for a selected host. ... Only Adobe® AIR® content running in the application security sandbox can use the URLRequestDefaults class.

所以,你只有一个选择:从那时候领域,需要授权的网页加载您的SWF。您将通过HTTP授权步骤之前,SWF加载和浏览器将保持休息。

So, you have but one option: load your swf from a web page of that very domain that requires authorization. You'll be through http authorization steps before swf is loaded and browser will maintain the rest.

事实上,当您试图访问位于HTTP授权的东西,一台服务器发出与code = 401 HTTP响应(除非你事先发送Authorization头)。 Flash Player可以对此无能为力,只有AIR运行时能够以任何方式发送授权头。

In fact, when you try to access something behind http authorization, a server issues a http response with code=401 (unless you send Authorization header beforehand). Flash Player can do nothing about it and only AIR runtime is capable of sending Authorization header in any way.

这篇关于AS3使用加载器加载一个文件htaccess的保护的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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