apache-flexrepeateraddchildviewstack

Flex viewstack addchild dynamically without recreating each child


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.


Solution

  • 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