【问题标题】:HttpService not working in<window> in adobe airHttpService 在 adobe air 中无法在 <window> 中工作
【发布时间】: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


【解决方案1】:

尝试将主窗口可见性设置为 false 而不是关闭它。我猜它可以认为你想终止你的应用程序(并且主窗口的所有子窗口也都关闭了)。

【讨论】:

  • 感谢您的建议,当我将 visible="false" 添加到 WindowedApplication 标签时,对于主窗口,它按预期工作。
猜你喜欢
  • 2013-11-07
  • 1970-01-01
  • 2013-06-12
  • 1970-01-01
  • 2018-03-11
  • 1970-01-01
  • 1970-01-01
  • 2016-03-04
  • 2018-12-14
相关资源
最近更新 更多