For Flex 2.0 Beginners - Use the mx:States and mx:ViewStack Tags To Change The Application's View

Introduction:

As a new Flex 2.0 developer coming from using HTML, JavaScript, CSS, DHTML, and ColdFusion, how to design a Flex application was confusing. HTML, even with AJAX, is primarily a page-oriented environment. If I needed to significantly change what the users sees, I would usually have the user go to a new web page. Most HTML-based applications are a series of connected web pages.

In Flex, there is not the concept of a page. Rather, Flex has several different ways for you change the "view" of your application. In this brief tutorial for beginners, I'll introduce two Flex controls: mx:States and mx:ViewStack. These two controls can be used together to change what your users see on screen in your Flex application.

[More]

Comments
Thanks for this article. I'm a developer just getting into Flex and have the basics of connecting to a cf backend and some of the Flex controls figured out. I have to say the States and ViewStack concept stumped a little at first.

You are right there is documentation around, i still think people coming from a traditional web based layout though ( new content = new page ) struggle a little with how to move through their application and which options are appropriate.

This shows clearly how to / advantages without worrying about the other bits and peices .. clear and concise :-)
# Posted By Mark | 3/11/07 4:29 AM
Hi Bruce.

You stuff is really informative. Been using your site as a learning tool for Flex. I was wondering if you had any ideas to change a viewstate via a combobox? Just curiuous. Any help/feedback is welcomed. Thanks again. Keep up the good work!
# Posted By Edwin Leung | 3/19/07 5:18 AM
Was also curious about controlling a viewstack via a combo box. Most of the other controls allow you to specify a view stack as the dataProvider. This doesn't appear to work with combo boxes. Any thoughts/suggestion you might have would be greatly appreciated.

Thanks.
# Posted By Joe | 3/19/07 8:43 AM
Joe and Edwin:
I've not done this but try using ApplicationControlBar that contains a combo box. On the combo box change event, have the function select a new child for the view stack that matches the label of the combo box.
# Posted By Bruce | 3/19/07 4:50 PM
I've tried exactly what you've suggested but for some reason the focus doesn't switch to the any of the children. I'll give it another shot once I have a few more hours of sleep logged. I'll let you know what I come up with.
# Posted By Joe | 3/19/07 6:02 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.1.004.