3 Replies Latest reply on Mar 2, 2010 12:48 PM by miguel8312

    loop ResultEvent for items

    miguel8312 Level 3

      hello everyone this would seem rather simple to do but im having a hell of a time trying to acomplish this.

      I  noticed that when i make a webservice call to my webservice the  ResultEvent is basically an array collection. i would like to basically loop this  array collection looking to see if there are any values being returned from the webservice.


      when i i debug  i see that the hierachy has this ms.utils.objectproxy   and it works down from there. I cant quite understand how does one go about accessing the objects being returned from the webserivce. i have tried several methods but im at a lost here. Can anyone point me the right direction I would really just like to evaluate the arraycollection being returned from the webservice to see if there are items being returned. i have also tried to change my resultformat of my webservice to "e4x" but sadly i just dont know where to got from there either.


      I have tried to do this also but all i get is [object object]

      trace(event.result.source[0].toString() , "right here")


      bottomline does anyone know how to loop throught the nodes of the ResultEvent? and or display them with a trace statement. i know i can just see the values when i debug but i would really like to evaluate the items being return for null or not ...

      thanks in advance for any help you guys can offer.






        • 1. Re: loop ResultEvent for items
          miguel8312 Level 3

          i have noticed that perhaps the best way to do this is to use e4x? However it appears that i have to parse throught all the xml add it to an arraycollection and  then bind it to my datagrid. Is there a better way.  When i used the object format for the webservice all i had to do was bind it to my datagrid and it would do all the heavy lifting?


          is there a way to use E4X to bing the the xml to datagrid automatically?



          can anyone throw me a bone here

          • 2. Re: loop ResultEvent for items
            Gregory Lafrance Level 6

            First you should have some idea of what is being returned by the web service. If it is XML, then set the resultFormat to e4x and use e4x syntax to process the data.


            If the data is being returned as an Array, then you can loop through it like this:


            for each(var item:Object in event.result as Array){




            If the trace is [object Object], then you may need to drill down into the data, lie maybe this:


            for each(var item:Object in event.result as Array){





            If this post answers your question or helps, please mark it as such.

            Greg Lafrance - Flex 2 and 3 ACE certified


            Flex / AIR Development, Training, and Support Services

            • 3. Re: loop ResultEvent for items
              miguel8312 Level 3

              greg you are an absolute genius!!! ive been playing around with how to do this for days!!!!... i started looking to E4X when i had no where to turn eventhought i dont think its time waste this is exactly what i need it. I googled and googled some more and i didnt find the answer anywhere.



              YOU ARE THE MAN!!!

              you have pulled me out the gutter once again

              thank you.


              hopefully this helps another noob by the defaul per the documention if you use the [Object] formatter on the webservice definition it (event.result) is of arraycollection type so as you can see i have modified your code just a bit then to access the item i just use the item name and VOILA!




               each(var item2:Object in event.result as ArrayCollection){