Packagemx.states
Classpublic class State
InheritanceState Inheritance flash.events.EventDispatcher

The State class defines a view state, a particular view of a component. For example, a product thumbnail could have two view states; a base view state with minimal information, and a rich view state with additional information. The overrides property specifies a set of child classes to add or remove from the base view state, and properties, styles, and event handlers to set when the view state is in effect.

You use the State class in the states property of Flex components. You can only specify a states property at the root of an application or a custom control, not on child controls.

You enable a view state by setting a component's currentState property.

MXML Syntaxexpanded Hide MXML Syntax

The <mx:State> tag has the following attributes:

  <mx:State
  Properties
  basedOn="null"
  name="null"
  overrides="null"
  />
  

Default MXML Propertyoverrides

See also

mx.states.AddChild
mx.states.RemoveChild
mx.states.SetEventHandler
mx.states.SetProperty
mx.states.SetStyle
mx.states.Transition


Public Properties
 PropertyDefined by
  basedOn : String
The name of the view state upon which this view state is based, or null if this view state is not based on a named view state.
State
  name : String
The name of the view state.
State
  overrides : Array
The overrides for this view state, as an Array of objects that implement the IOverride interface.
State
Public Methods
 MethodDefined by
  
Constructor.
State
Events
 EventSummaryDefined by
   Dispatched when the view state has been entered.State
   Dispatched before a view state is exited.State
Property detail
basedOnproperty
public var basedOn:String

The name of the view state upon which this view state is based, or null if this view state is not based on a named view state. If this value is null, the view state is based on a root state that consists of the properties, styles, event handlers, and children that you define for a component without using a State class.

The default value is null.

nameproperty 
public var name:String

The name of the view state. State names must be unique for a given component. This property must be set.

overridesproperty 
public var overrides:Array

The overrides for this view state, as an Array of objects that implement the IOverride interface. These overrides are applied in order when the state is entered, and removed in reverse order when the state is exited.

The following Flex classes implement the IOverride interface and let you define the view state characteristics:

The overrides property is the default property of the State class. You can omit the <mx:overrides> tag and its child <mx:Array>tag if you use MXML tag syntax to define the overrides.

Constructor detail
State()constructor
public function State()

Constructor.

Event detail
enterStateevent 
Event object type: mx.events.FlexEvent
FlexEvent.type property = mx.events.FlexEvent.ENTER_STATE

Dispatched when the view state has been entered. This event is dispatched after the changes to the base view state have been applied.

The FlexEvent.ENTER_STATE constant defines the value of the type property of the event object for a enterState event.

The properties of the event object have the following values:

PropertyValue
bubblesfalse
cancelablefalse
currentTargetThe Object that defines the event listener that handles the event. For example, if you use myButton.addEventListener() to register an event listener, myButton is the value of the currentTarget.
targetThe Object that dispatched the event; it is not always the Object listening for the event. Use the currentTarget property to always access the Object listening for the event.
exitStateevent  
Event object type: mx.events.FlexEvent
FlexEvent.type property = mx.events.FlexEvent.EXIT_STATE

Dispatched before a view state is exited. This event is dispatched before the changes to the base view state have been removed.

The FlexEvent.EXIT_STATE constant defines the value of the type property of the event object for a exitState event.

The properties of the event object have the following values:

PropertyValue
bubblesfalse
cancelablefalse
currentTargetThe Object that defines the event listener that handles the event. For example, if you use myButton.addEventListener() to register an event listener, myButton is the value of the currentTarget.
targetThe Object that dispatched the event; it is not always the Object listening for the event. Use the currentTarget property to always access the Object listening for the event.