Chapter 12. 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 (and every Flex component) 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 for an application, and you can create states for components. The process for creating states for either is identical (remember that applications and components both inherit from UIComponent, which is what defines the ability to work with states). You can create states using ActionScript or using MXML. ...

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