10 Replies Latest reply on Sep 21, 2010 7:07 PM by nicola_g

    Remove all children from application container

    nicola_g

      Hi guys,

       

      I have a portion of script in my flex application (.mxml) like this:

       

      public function remove_all_children():void {

          var n:int = this.rawChildren.numChildren;

          var i:int;


          for (i=0; i<n; i++)

              this.rawChildren.removeChildAt(i);

      }

       

      I have to make this function because "this.removeAllChildren" doesn't work,

      and "this.rawChildren" doesn't have a function called removeAllChildren.

      But I guess this script will fail when the numChildren is smaller than the largest index of children.

      I believe it fails in this case because there's an existing function in rawChildren to set the index

      of a child: rawChildren.setChildIndex. What if I set the index of a child to be 999999?