0 Replies Latest reply on Aug 30, 2010 12:03 AM by Deh Bontempos

    Adding several items to db using call responder = /

    Deh Bontempos

      Hi!

       

      why this is not working?

       

      protected function bt_confirm_clickHandler(event:MouseEvent):void
                  {
                      buildItemsAC(); // this only creat an arrayCollection called itemsAC, full of "items" to add.
                     
                      var toAdd:int = itemsAC.length;
                      addOne();
                     
                      function addOne():void
                      {                   
                          createItemsResult.token = itemsService.createItems(itemsAC.getItemAt(toAdd-1) as Items);
                          createItemsResult.addEventListener(ResultEvent.RESULT,reportback);
                         
                          toAdd--;
                      }
                                     
                      function reportback(e:ResultEvent):void
                      {
                          if(toAdd > 0)
                          {
                              addOne();   //listener is working only once
                          }
                          else
                          {
                              Alert.show("Added ok");
                          }
                      }
                  }

       

      Is there another simplest way to add a list of items to data bank like this?

      I couldnt create a loop because it was overriding the items while calling the call responder.... =////

       

      What do you think I should work around?

       

      Thanks,

       

      btp~