Flex viewstack addchild dynamically without recreating each child

610 Views Asked by At

I have a viewstack with a repeater inside to create each child. Soemthing like that:

    <mx:ViewStack width="100%" height="100%" >
    <mx:Repeater id="myrepeater" dataProvider="{myDataProvider}">
    <mx:HBox width="100%" height="100%" >
    ---view content goes here---
    </mx:HBox>
    </mx:Repeater>  
    </mx:ViewStack>

When I add an item to the dataprovider, it creates the new child, but it also reloads all the other children, which I don't want. How do I prevent Flex from recreating the component when it adds a child?

Thanks.

2

There are 2 best solutions below

1
fabio trabattoni On BEST ANSWER

You can't do it "incrementally" with a Repeater, you should do it programmatically instead using the method addChild() which belongs to Container hence it's inherited by, for example, the HBox at the first level inside your Repeater,

cheers

0
Peter Hall On

If you can use Flex 4 or higher, then use a DataGroup or a List instead of a Repeater. Everything will just work better.

Otherwise, you can try setting recycleChildren=false on the Repeater.