1 Reply Latest reply on Apr 15, 2010 3:30 PM by peteandrus

    am i handling this RemoteObject correctly?

    peteandrus Level 1

      my handler function is not catching a ResultEvent correctly the way it should. Here is the code:

       

      public class PagedDataGrid_Controller
          {
              //var recipIDFetcher:RemoteObject;
              private var model:PagedDataGrid_Model;
              private var recipIDFetcher:RemoteObject;
              public function PagedDataGrid_Controller(IN:PagedDataGrid_Model)
              {
                  recipIDFetcher = new RemoteObject("recipReferenceQuery");
                  recipIDFetcher.searchResults1.addEventListener(ResultEvent.RESULT,dealWithRecipQueryResul t);
                  model = IN;
              }
              public function dealWithRecipQueryResult(event:ResultEvent):void
              {
                  model.ids = event.result as ArrayCollection;
              }
              public function dealWithRecipQuery():void{
                  recipIDFetcher.searchResults1();
              }
          }

       

      my remote object has a method called searchResults1. i am wondering if i should change the line:

      recipIDFetcher.searchResults1.addEventListener(ResultEvent.RESULT,dealWithRecipQueryResult );

      to

      recipIDFetcher.addEventListener(ResultEvent.RESULT,dealWithRecipQueryResult);

      ?

       

      can anyone spot any problems here? i know this object works right because i've used it before. thanks!

        • 1. Re: am i handling this RemoteObject correctly?
          peteandrus Level 1

          nevermind, i figured it out. i wasn't catching the fault event, which of course is what was happening! thanks

           

          new code for posterity's sake:

           

              public class PagedDataGrid_Controller
              {
                  //var recipIDFetcher:RemoteObject;
                  private var model:PagedDataGrid_Model;
                  private var recipIDFetcher:RemoteObject;
                  public function PagedDataGrid_Controller(IN:PagedDataGrid_Model)
                  {
                      recipIDFetcher = new RemoteObject("recipReferenceQuery");
                      recipIDFetcher.addEventListener(ResultEvent.RESULT,dealWithRecipQueryResult);
                      recipIDFetcher.addEventListener(FaultEvent.FAULT,dealWithRecipQueryFault);
                      model = IN;
                  }
                  public function dealWithRecipQueryResult(event:ResultEvent):void
                  {
                      model.ids = event.result as ArrayCollection;
                  }
                  public function dealWithRecipQueryFault(event:FaultEvent):void
                  {
                      var fault:String = event.message.toString();
                  }
                  public function dealWithRecipQuery():void{
                      recipIDFetcher.searchResults1();
                  }
              }