apache-flexflashviewstack

Low Overhead Dynamic Tab/ViewStack in Flex?


Suppose I have a ViewStack like this:

<mx:ViewStack id="s" left="5" right="5" bottom="5" top="0" width="100%" height="100%" creationPolicy="all"  minHeight="0">
    <mx:Repeater id="repeater" dataProvider="{dp}" height="100%" width="100%" minHeight="0">
        <mx:Box id="bx" label="{repeater.currentItem.label}" width="100%" height="100%" minHeight="0">
            <mx:Label minHeight="0" width="100%" height="100%" label="bob" />
        </mx:Box>
    </mx:Repeater>
</mx:ViewStack>

With a large number of items in the stack (each having a large number of panels, databinding, etc), this gets extremely slow. The Repeater seems to trigger creation of all children regardless of the creationPolicy of the viewStack itself.

Is there a readymade solution to this efficiency problem? I can think of some ways to solve it with a custom component, but I'm wondering if there's an off the shelf solution for cases where the inner values really need to be dynamic (backed by an ArrayCollection) like this.


Solution

  • Assuming that all your stacked views are identical except for some specific data displayed in them a possible solution would be to ditch the viewstack and set up all your controls to bind to an array collection, then whatever control you would use to change your viewstack could instead update your array collection.