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!
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.
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.
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
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.
I've never seen an experienced Flex developer say they prefer states over ViewStacks. I never use states anymore, personally. Maybe in Flex 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,
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.
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.