1 Reply Latest reply on Aug 26, 2010 12:49 PM by camfieldaj

    Reusing an HTTPService to populate several controls


      I am creating an interface that looks up the contents of 5 text files (not xml, not php) and populates 5 arrays with the text of each.

      I could use a separate HTTPService for each, but that seems inefficient, especially when this scales to 30+ lookups.


      How do I create a loop that runs through a series of lookups from the following base code? Is it possible in the .send to specify the variable name of the result, instead of having a separate function to do that?


      The basic structure to do a single lookup on the first of my desired sequence when a button calls the doTheLookUps function:


      <mx:HTTPService id="lookUp" url="{pathToLookUp}" result="{getResult(event)}" />


      var lookUpPath1:String = new String ("fileName1");

      var lookUpPath2:String = new String ("fileName2");

      var lookUpPath3:String = new String ("fileName3");


      var holderArray1:ArrayCollection = new ArrayCollection;

      var holderArray2:ArrayCollection = new ArrayCollection;

      var holderArray3:ArrayCollection = new ArrayCollection;


      public function doTheLookUps ():void {

           pathToLookUp = lookUpPath1;




      public function getResult(evt:ResultEvent):void {

           holderArray1 = new ArrayCollection(lookup.lastResult.toString();






      I've tried nesting these two functions inside another that could contain a loop that changes the variable names, but then I get an error about a possibly undefined method getResult, since it is being called by the HTTPService.


      Any thoughts?