4 Replies Latest reply on Apr 23, 2009 5:30 PM by ntsiii

    Get Results From RemoteObject

    Miggl Level 1

      Not sure what's gotten into me today... feel like I'm loosing it.

       

      I'm getting a list of users back from a RemoteObject method call. I can't seem to remember how to parse them out. Is this the appropriate method?

      private function loadUsersByGroupHandler(event:ResultEvent):void
      {
           try
           {
                this._assignedUsers = event.result as ArrayCollection;
           }
           catch (error:FaultEvent)
           {
                this.parentDocument.faultHandle(event);
           }
      }
      

       

      The problem here is that when I do this, I am unable to inspect the resulting ArrayCollection for length or anything else, as the following fails (no error is thrown, but also no alert is shown):

      private function loadUsersByGroupHandler(event:ResultEvent):void
      {
           try
           {
                     Alert.show(ArrayCollection(event.result).length.toString());
                this._assignedUsers = event.result as ArrayCollection;
           }
           catch (error:FaultEvent)
           {
                this.parentDocument.faultHandle(event);
           }
      }
        • 1. Re: Get Results From RemoteObject
          Michael Borbor Level 4

          Try this._myAC= new ArrayCollection( event.result as Array)

           

          Sincerely,

           

          Michael

           

          El 22/04/2009, a las 14:22, Miggl <forums@adobe.com> escribió:

           

          >

          Not sure what's gotten into me today... feel like I'm loosing it.

          >

          I'm getting a list of users back from a RemoteObject method call. I 

          can't seem to remember how to parse them out. Is this the 

          appropriate method?

          private function loadUsersByGroupHandler(event:ResultEvent):void

          {

               try

               {

                    this._assignedUsers = event.result as ArrayCollection;

               }

               catch (error:FaultEvent)

               {

                    this.parentDocument .faultHandle(event);

               }

          }

          >

          >

          The problem here is that when I do this, I am unable to inspect the 

          resulting ArrayCollection for length or anything else, as the 

          following fails (no error is thrown, but also no alert is shown):

          private function loadUsersByGroupHandler(event:ResultEvent):void

          {

               try

               {

                           

          Alert.show(ArrayCollection(event.result).length.toString());

                    this._assignedUsers = event.result as ArrayCollection;

               }

               catch (error:FaultEvent)

               {

                    this.parentDocument .faultHandle(event);

               }

          }

          >

          • 2. Re: Get Results From RemoteObject
            Miggl Level 1

            That would fix it! Thanks.

             

            Can anyone explain why I have to ppass in an Array into an ArrayObject? I was under the impression that Arrays and ArrayObjects were essentially equal, other than that ArrayCollections can update Dynamically.

             

            Thanks,

            Mike

            • 3. Re: Get Results From RemoteObject
              Michael Borbor Level 4

              Not really an array expects a generic object, while the AC expects an 

              Array take a look at the docs to understand more about this.

               

              Sincerely,

               

              Michael

               

              El 22/04/2009, a las 14:46, Miggl <forums@adobe.com> escribió:

               

              >

              That would fix it! Thanks.

              >

              Can anyone explain why I have to ppass in an Array into an 

              ArrayObject? I was under the impression that Arrays and ArrayObjects 

              were essentially equal, other than that ArrayCollections can update 

              Dynamically.

              >

              Thanks,

              Mike

              >

              • 4. Re: Get Results From RemoteObject
                ntsiii Level 3

                "...Arrays and ArrayObjects[sic] were essentially equal..."  No, not at all.  ArrayCollection has much more functionality than Array, including a full API.

                 

                Further, on you original issue, the "as" operator requires that the reference on the left side contains an object of the type on the right of the operator. While it might be possible that the remote call's event.data reference contains a Flex collection, it is not very likely.  ObjUtil has some methods for inspecting objects.

                 

                Tracy Spratt