1 Reply Latest reply on Oct 5, 2007 5:47 AM by JKohn99

    removing children from List causes visual bug

    hillemania01
      Hello,
      I'm new to Flex so I apologize if this is basic and trivial.

      I have a list that I'm using some databinding with some search results. After the initial search I need to clear out all of the children in the list before running the next search otherwise it just gets tacked onto the bottom. When I try running removeChild for all of the children nodes in the list it removes the items, but then does something to the visual display and leaves a giant gray box. I know that the new data is being loaded in as the scrollbar changes size to indicate that there are elements, but it's just all gray.

      Is there some sort of a re-draw function that needs to take place or is there an error with my method of clearing the contents?
        • 1. Re: removing children from List causes visual bug
          JKohn99 Level 1
          removeChild removes a DisplayObject from it's container.

          You seem to want to clean up the result list before you fetch new results.

          I assume you have the following:

          [Bindable]
          private var myList:ArrayCollection ;

          <mx:List dataProvider="{myList}" .../>

          Before you fetch your next set of results, clear myList.

          myList.removeAll() or whatever is appropiate.

          It is always best practice to manipulate the dataprovider for the visual
          controls. DataBinding will update the control as appropriate.