2012-12-22 46 views
0

我有一个窗口应用程序作为我的基础应用程序。要避免任务栏中应用程序的选项卡栏图标,我关闭本机窗口并从另一个窗口打开内容。 在这里,我将调用http服务方法。但没有任何反应,并且在编译和运行时没有显示错误。 所有其他操作都正常。为什么我不能窗口中调用HTTP服务在Adobe AIRHttpService不工作在<window>土坯空气

代码在主应用程序中打开新的窗口:

<?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> 
+0

你是否在调试模式下使用httpService,httpResult和httpFault中的断点运行代码?您是否使用过网络嗅探器(例如Flash Builder网络监视器)来检查呼叫以查看您是否收到响应?由于dataResult和faultString是结果和错误处理程序的局部变量;他们将不在这些方法的范围之外;这可能会导致意想不到的问题,具体取决于您要做什么以及返回的数据。 – JeffryHouser

回答

1

尝试设置您的主:对于窗口

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); 


      } 

代码窗口可见性为false而不是关闭它。我想它可以认为你想终止你的应用程序(并且主窗口的所有子窗口也关闭)。

+0

感谢您的建议,当我为WindowedApplication标签添加visible =“false”时,对于主窗口,其按预期工作。 – Nancy