Chapter 12. WORKING WITH VIEW STATES

View states are among the most powerful features for building a dynamic, flexible user interface. They allow you to specify different arrangements of your application at a specific time for a specific purpose. Consider a web application that has both a login page and a user preferences page—you can think of these two pages as the HTML equivalent of view states in Flex.

States provide a way to group a set of changes to the UI into understandable chunks—essentially, a state is a collection of changes to properties, styles, or behaviors of a component. While a developer could do this through sets of functions that make a batch of changes to the UI, the MXML that Flex states use is much more readable and easier to write—and with Flex Builder, it can all be created in a natural, visual way.

Scenarios for States

Think about the search application you built in Chapter 8. In that example, the person using your application sees a results list and a search field when they load the application. That’s all fine and good, but it doesn’t make sense to show a results list until there are actual results to view.

Of course, you could set the results list to initially invisible and then set it back to visible once there are results. However, you might want more changes to occur in the UI when results appear. For instance, it would be nice if when the application starts, the search fields are large and are the only user interface elements showing. To help direct the ...

Get Learning Flex 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.