10 Replies Latest reply on Jul 7, 2009 10:55 AM by Gregory Lafrance

    ViewStacks vs. states

    spacehog Level 1
      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?

      Each tool page looks identical. They each have a TabNavigator with the same tabs on them (description, features, documentation, training). Each tab just displays the tool specific data for that tab.

      To me it shounds like I should be using states. Having one TabNavigator that changes the data based on the state which is powered by the clickEvent.

      Any input would be appreciated.
        • 1. Re: ViewStacks vs. states
          boxdoctor Level 1
          Hey there. I personally have used viewstates in my navigation components just because I like being able to control what is being shown either by doing it via the design mode or the code itself. It seems to work very well, but I have read that viewstacks kind of fall right into the navigation components like accordion etc. So leave it to me to be different.

          I basically have the various views being controlled by one function which makes it a really lean mean interface. So when someone clicks a button, the button label property is passed into the single function which then changes the currentView to match the viewstate accordingly.

          May not be the best way, but I thought I'd chime in letting you know that I do like using the viewstates in regards to a "navigational type system" and that it does work pretty well just in case you were thinking of trying it and didn't know if the outcome would be good.

          Hope it helps!
          • 2. Re: ViewStacks vs. states
            splitzer Level 1
            I just started making flex applications, viewstacks solves all my problems, i havent got a chance to put my hands on states, maybe i'll try that out too.
            • 3. Re: ViewStacks vs. states
              IMBO,Large system use ViewStack better,an apps include states,but have a question,flex like flash state only limit 10 scenes or nolimited? my ViewStack websits URI: http://www.freehere.cn
              • 4. Re: ViewStacks vs. states
                spacehog Level 1
                From what I am hearing most people are using viewstacks. I am just thinking states would deliver a smaller package to the end user (because you are essentially using the same components in each state).

                The problem I have with states is that it seems a nighmare trying to keep track of them. In my current app, if I were using states for each click event I would already have a couple dozen states. And I am nowhere near finished.
                • 5. Re: ViewStacks vs. states
                  boxdoctor Level 1
                  I think you're correct in that it would deliver a smaller package, although I can't say for sure. The nice thing about the states is that the design view keeps a very good record of them, and it's kind of easy IMHO that to see what a "click" would do on a single button. I've got about 2 dozen buttons and the code isn't much larger than 500 lines...but again I think that's because of the single changeState function I created that all my clickevents pass to.

                  And in answer to Yang, I have about 24 states right now and it is fast as can be, so there doesn't appear to be a limit yet.....LOL
                  • 6. Re: ViewStacks vs. states

                    Hey  guys,

                       This is a great thread started.  I am currently updateing my flex app, and sure enough managing my states is causing an issue.  Pertty much everyone has stated to use viewstack or some other method, can anyone elaborate? an example or two?


                       I have an application navbar that uses viewstack to display few pages, but than within each page I have states that display data as use clicks through links/buttons/pie charts and searches.




                    • 7. Re: ViewStacks vs. states
                      Ansury Level 3

                      I've never seen an experienced Flex developer say they prefer states over ViewStacks.  I never use states anymore, personally.  Maybe in Flex 4...

                      • 8. Re: ViewStacks vs. states
                        leybniz Level 4


                        states cause me some architectural problems,

                        even simple usecase: login/logout/login[another user] won't allow to easily cleanup state-based UI from the data left from previous user.


                        With ViewStacks you are able to add childs dynamically as needed and remove them after they have no use left,

                        • 9. Re: ViewStacks vs. states
                          kingquattro Level 1

                          All of this is great, perhaps and example or a pointer for a new newbee like myself would help us understand how to implement such solutions.  The use case of login/register/logout/login would be a good start.  Most of the examples I have come across, uses states.



                          • 10. Re: ViewStacks vs. states
                            Gregory Lafrance Level 6

                            Use states for small components, like the typical login form that changes state to a register form is necessary.


                            Viewstacks are used far more frequently.