When to Use States

States are a powerful and extremely useful feature of the Flex framework. You can accomplish many things using states. In fact, you can use states for so many things that it’s possible to use them in ways for which they are not really designed. States are very closely associated with the view, so they should be used for things that affect the view or changes in behavior associated with the view (in the case of setting event handlers). Although you could easily use states to change data models, for example, it’s not an appropriate use. To better understand the most appropriate use of states, consider the following guidelines for when to use them:

For applying a transition effect

If you want to use a transition, you ought to use states.

For changing or replacing all or part of a screen

If you’re adding or removing components, states are usually the most appropriate choice.

There are some gray areas that make states an unlikely choice. For example, you might have a form with a text input control that is disabled until the user selects a checkbox. You could use states for that, but unless you want to apply a transition, it is probably much more appropriate to simply use ActionScript triggered by the click event of the checkbox.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset