1 Reply Latest reply on Mar 14, 2011 2:30 AM by Nuwan,Chamara

    cannot add multiple childs to form

    smartkiran143

      I am writing the following code to add multimple childs dynamically to a form..

       

      protected function getcseStaff_resultHandler(event:ResultEvent):void

      {

      var i:int;

      i=0;

      var newComp:Staff=new Staff();

      var fm:FormItem = new FormItem();

      for each(var row:XML in event.result.children())

      {

      newComp.lectname=event.result.prof[i].name;

      newComp.photo=event.result.prof[i].photo;

      newComp.degree=event.result.prof[i].degree;

      newComp.desig=event.result.prof[i].desig;

      newComp.exper=event.result.prof[i].experience;

      testing.text=testing.text+event.result.prof[i].name;

      i++;

      fm.addChild(newComp);

      idCseStaffForm.addChild(fm);

       

       

      }

       

       

      }

       

       

       

      But, only the last element of my xml file is being added.. There is no error with xml file. I have cross checked by loading data into a text box..

       

      The problem is am unable to add multiple childs..

       

       

      please help me..

       

       

      I actually need something.. not a form.. I need to display all my components as small thumbnails.. like multiple rowscontaining 3 or 4 in each row side by side..

       

       

      Pease help me...

       

        • 1. Re: cannot add multiple childs to form
          Nuwan,Chamara Level 1

          Hi,

           

          Well I think you need to instantiate Staff and FormItem inside the for each loop.

           

          protected function getcseStaff_resultHandler(event:ResultEvent):void

          {

          var i:int;

          i=0;

           

          for each(var row:XML in event.result.children())

          {

          var newComp:Staff=new Staff();

          var fm:FormItem = new FormItem();

          newComp.lectname=event.result.prof[i].name;

          newComp.photo=event.result.prof[i].photo;

          newComp.degree=event.result.prof[i].degree;

          newComp.desig=event.result.prof[i].desig;

          newComp.exper=event.result.prof[i].experience;

          testing.text=testing.text+event.result.prof[i].name;

          i++;

          fm.addChild(newComp);

          idCseStaffForm.addChild(fm);

           

           

          }

           

           

          }