R – viewstacks vs states in flex

actionscript-3airapache-flexflashflex3

I have an app that I am currently using a viewstack to display each page and I am wondering is this the right way to go, or should I use different states (or something else).

The site is powered by a menu bar with the top level items of Home, Tools, Support. Underneath the Tools menu is a submenu with Tool1, Tool2, Tool3. Currently when the user clicks on any of the tools in the Tool submenu I bring up a child container from the viewstack (each child is actually in a separete component).

Is this the right way to go, or should I be using states to bring up the appropriate elements for each tool page?

Best Answer

It depends on how different the views are. If they are very similar, states are good because they help to effectively reuse a lot of markup already defined in the base component. If they are very different views, the states will be harder to for other developers to maintain because it's not as straightforward as separate components for each view.

Also ViewStack allows for deferred instantiation to be used. This is controlled by the "creationPolicy" attribute. DI means your app will load faster because only the first child of the ViewStack will be instantiated intially. As you navigate to the other children, they will instantiated on demand.

Related Topic