【发布时间】:2012-12-22 13:12:06
【问题描述】:
我有一个窗口应用程序作为我的基本应用程序。为了避免任务栏中应用程序的标签栏图标,我关闭了本机窗口并从另一个窗口打开内容。 这里我将调用http服务方法。但是没有任何反应,编译和运行时也没有显示错误。 所有其他操作都工作正常。为什么我无法在 adobe air 的窗口内调用 http 服务
在主应用程序中打开新窗口的代码:
public function init():void {
nativeWindow.close();
var newWindow:MyWin = new MyWin();
newWindow.systemChrome = NativeWindowSystemChrome.NONE;
newWindow.type = NativeWindowType.LIGHTWEIGHT;
newWindow.transparent = true;
newWindow.open(true);
}
窗口代码:
<?xml version="1.0" encoding="utf-8"?>
<mx:Window name="MyWin"
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="httpService()" >
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.http.HTTPService;
public function httpService():void {
var httpSer : HTTPService = new HTTPService();
httpSer.url = "http://flexairapp...";
httpSer.method = "GET";
httpSer.addEventListener(ResultEvent.RESULT, httpResult);
httpSer.addEventListener(FaultEvent.FAULT, httpFault);
httpSer.resultFormat="text";
var parameters:Object = new Object();
httpSer.send();
}
public function httpResult(event:ResultEvent):void {
var dataResult:String = event.result.toString();
}
public function httpFault(event:FaultEvent):void {
var faultstring:String = event.fault.faultDetail;
}
]]>
</fx:Script>
</mx:Window>
【问题讨论】:
-
您是否在调试模式下运行代码并在 httpService、httpResult 和 httpFault 中设置断点?您是否使用过网络嗅探器(例如 Flash Builder 网络监视器)来检查调用以查看是否得到响应?由于 dataResult 和 faultString 是结果和错误处理程序的局部变量;在这些方法的范围之外,它们将不可用;这可能会导致意外问题,具体取决于您尝试使用返回的数据执行的操作。
标签: apache-flex air adobe