5 Replies Latest reply on Mar 12, 2010 2:49 AM by tchavezCodes99

    Help with multiple httpservice calls

    tchavezCodes99

      I need help with multiple httpservice call back to back, doing 10 different mysql query at startup of the app loading results into 14 datagrids/combobox all queries are to different tables.

        • 1. Re: Help with multiple httpservice calls
          Matt Le Fevre Level 4

          do them sequentially, calling the next service in the result event of the previous one.

          • 2. Re: Help with multiple httpservice calls
            tchavezCodes99 Level 1

            can you give me a simple example of what you mean? Currently I have:

             

            private function init():void {

            getData1.send();

            getData2.send();

            getData3.send();

            getData4.send();

            getData5.send();

            getData6.send();

            }

            • 3. Re: Help with multiple httpservice calls
              PDL_AGH

              Hello,

               

              I think what Grizzzzzzzzzz means is the following:

               

                  <mx:HTTPService id="serviceOne"
                      url="here goes url"
                      result="resultHandler1(event);"
                      fault="faultHandler(event);"/>

               

                  <mx:HTTPService id="serviceTwo"

                      url="here goes url"

                      result="resultHandler2(event);"

                      fault="faultHandler(event);"/>

               

                  <mx:HTTPService id="serviceThree"

                      url="here goes url"

                      result="resultHandler3(event);"

                      fault="faultHandler(event);"/>


                   // Result handler 1
                   private function resultHandler1(event:ResultEvent):void{
                        //Here do something with the results
                       xmlCollection = event.result as XML;

               

                       //then call the next service
                       serviceTwo.send();
                   }


                    // Result handler 2
                    private function resultHandler2(event:ResultEvent):void{
                        //Here do something with the results

                       xmlCollection = event.result as XML;

               

                       //then call the next service
                        serviceThree.send();
                    }

               

              I hope this helps,

              Pierre

              • 4. Re: Help with multiple httpservice calls
                Matt Le Fevre Level 4

                tchavezCodes99 wrote:

                 

                can you give me a simple example of what you mean? Currently I have:

                 

                private function init():void {

                getData1.send();

                getData2.send();

                getData3.send();

                getData4.send();

                getData5.send();

                getData6.send();

                }

                 

                PDL_AGH has summed up what i meant

                 

                basically this'll keep your code tidyer, and prevent your server from being flooded with requests. It'll fill each of your datagrids in succession rather than randomly depending when each service result is returned.

                 

                It also means you'll never have more than 1 request occuring at any one time, which is something you should always try to avoid where possible.

                • 5. Re: Help with multiple httpservice calls
                  tchavezCodes99 Level 1

                  Thanks for the help it ends up my problem is something totally else. I was doing what you stated when I first made the connections. The real problem is that I have components inside a canvas on an accordian and the components on the accordin panels that are not selected dont load the data but once the accordin panel is selected data can be loaded into it.

                   

                  Ex:

                   

                  Panel 1 (everthing in this panel will load)

                       |

                       |

                       |

                       |

                  Panel2 (nothing in these panels load until the panel is selected then I have to trigger a service2.send())

                  Panel3

                  Panel4