Chapter 13. Working with View States

IN THIS CHAPTER

Scenarios for States

Managing States in Design Mode

Making a Login/Registration Form

Applying States to the Search Application

Summary

“How’s that shopping cart coming?” ... ... “...how ’bout now?”

Chris Giesey

View states can add another level of dynamics to your UI. States allow you to present different layout arrangements to support specific conditions. For instance, an application that recognizes different permissions between user accounts might provide a read-only state for some users while enabling an editing state for managers and administrators.

States provide a clean method of grouping modest UI changes into organized, understandable chunks. In other words, a state is a collection of changes to properties, styles, or behaviors of your UI components.

Of course, a developer could accomplish the same results using a series of functions to impose a batch of changes to the UI, but the MXML approach used by Flex is both easier to read and quicker to write—and with Flash Builder, you can always use Design mode to help you get started.

Scenarios for States

Think about the YahooSearch application you built in Chapter 11. In that example, the person using your utility sees an empty results list and the search field when she loads the application. Although there’s nothing mechanically wrong with that, it doesn’t make sense to show the results list until there are actual results to view. You could set the results list to invisible when the ...

Get Learning Flex 4 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.