Chapter 10. Managing State

In Flex terminology, a state is a collection of changes (called overrides) to a view. The overrides can comprise additions or removals of components as well as changes to their properties and behaviors. Every Flex application has at least one state, referred to as its base state. Flex states enable you to more easily change the view for an application, whether at a macro or a micro level. For example, you can define two states that act as screens in an application (e.g., a login screen and a menu screen). Using states for screens is an example of a macro-level use. At the micro level, you can use states to manage cascading forms and even different views for components (e.g., rollover changes).

The Flex framework provides an entire library for states and state management. You can create and manage states from MXML or ActionScript. Furthermore, you can use states in conjunction with other Flex features, such as transitions and history management, to create robust, responsive, and engaging applications and user interfaces with relative ease. In this chapter, you’ll learn how to work with Flex states.

Creating States

You can create states at the application level and at the component level. The process for creating states at either level is identical. Although you can create states using ActionScript, it is far more common and practical to create all states using MXML. States are part of the view of an application, and as with any part of the view in a Flex application, ...

Get Programming Flex 2 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.