3 Replies Latest reply on May 23, 2007 9:22 AM by SUNITAR

    Flex help


      This is what I want to do. I want to call this function which will process 3 steps. The function is like this.
      public function Insert():void {

      for (var i:int = 0; i < myData.length; i++ ) {

      //pull each Person object out of the ArrayCollection
      //and assign it to a variable of Person type
      var newProduct:Product = myData ;

      myService.insertsp( newProduct ) ;
      }//end for loop

      var uv:URLVariables = new URLVariables();
      var request:URLRequest = new URLRequest("OrderReview.html");
      uv.ordern = lblordern.text;


      But what it does before processing the loop. It jumps to the 3rd step. How can I fix it so that 3rd step will run only after the 2nd step. Is there a similar kind of function like 'waitfor()' in java in Flex2? Please help..

      Thanks in advance..
        • 1. Re: Flex help
          jensen.axel Level 1
          You should probably create some sort of javascript function and call it by using ExternalInterface.call("method","arg1");

          I'm not sure if that syntax is perfect, so look up the documentation... but flash waits it has to do with calls being asynchronous, and synchronous...

          i had the exact same problem, here is the blog post

          • 2. Re: Flex help
            Benjamin Houdu
            Well maybe working on your object 'myService' : give two parameters to your myService with an int = i inside your loop.
            Then check this int in your insertsp function and when this int == myData.length launch your 3rd part of code there (suppress it from your function insert).

            It's a problem to control very efficiently sequences of actions in Flex, but if you want to do so, I think it is better to separate into many functions and wait each time for the upper one (just like this time with your loop).
            • 3. Re: Flex help
              SUNITAR Level 1
              Thanks a lot for your reply. But my NavigateToUrl function is not inside the loop. The loop is for inserting data into a sql server table. I just want the third step to run after the loop is finished. It was working fine for 3-5 records. But when there are more records it just doesn't wait and executes the third step.. Is there any way ?