flash AS3 IDE and Flex HTTPService library



有谁知道是否可以在AS3中将Flex HTTPService库与Flash IDE一起使用?

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/rpc/http/HTTPService.html

或者,如果有一个类似的库可以使用它做同样的事情?

基本上,我正在连接到HTTPS地址并发布一些标头以再次访问REST服务,这一切都可以通过Flash IDE/Player完美运行。

一旦我将完全相同的代码导出到桌面版 AIR 就会出现 405 错误(显然桌面版 AIR 没有沙盒冲突,我已经为其他 URL 尝试过此操作,但它有效,但不适用于此 HTTPS 地址)。

显然对 REST/HTTPS 地址进行完全相同的调用,但使用 Flex HTTPService 有效? 有人知道为什么会这样或知道任何解决方法吗?

好的,

所以我设法找到了一个解决方法,希望这对其他人有所帮助。

我使用了上面提到的 flex HTTPService 我让它工作的方式是将 flex SWC 包含在 Actionscript 3.0 设置库路径中;"rpc.swc"和"framework.swc"。

下面是一些代码和导入使用。

import mx.rpc.events.*;
import mx.rpc.http.*;
var httpService : HTTPService = new HTTPService();
httpService.method = HTTPRequestMessage.GET_METHOD;
httpService.headers["Username"] = "user";
httpService.headers["Password"] = "pass";
httpService.url = "https://...../";
httpService.resultFormat = "e4x";
httpService.addEventListener( ResultEvent.RESULT, resultFunction );
httpService.addEventListener( FaultEvent.FAULT, faultFunction );
httpService.send();
function resultFunction(result: ResultEvent):void{
    //String(result.result);
}
function faultFunction(event: FaultEvent) : void{
    //String(event.fault);
}

最新更新