2 Replies Latest reply on Feb 25, 2008 10:51 AM by ntsiii

    RemoveChild

    jefflemon Level 1
      I have a container that various images and text is added to dynamically with addChild...

      Is there any way to delete all the childs ive added?

      For example:
      I display an image with add child inside a function, when the function is called again, but the previous image is still there... I need to clear the container before calling the function again...
        • 1. Re: RemoveChild
          jefflemon Level 1
          anyone?
          • 2. Re: RemoveChild
            ntsiii Level 3
            This is one good reason to use mx:Repeater instead of manually using addChild / removeChild, it handles that stuff for you.

            To do it manually, you can loop over the container's child list. Of course, if there any non-dynamic children, that will add complexity. Use Repeater.

            Or, when you create the children, maintain a reference to each in some structure, an Array, or Associative Array(object). You can thn loop over these reference and use removeChild();

            Repeater is much simpler.

            Tracy