Packagefeathers.utils.touch
Classpublic class TouchToState
InheritanceTouchToState Inheritance Object
Subclasses DelayedDownTouchToState

Product Version : Feathers 3.2.0

Changes a target's state based on the TouchPhase when the target is touched. Conveniently handles all TouchEvent listeners automatically. Useful for custom item renderers that should be change state based on touch.

See also

feathers.utils.keyboard.KeyToState


Public Properties
 PropertyDefined By
  callback : Function
The function to call when the state is changed.
TouchToState
  currentState : String
[read-only] The current state of the utility.
TouchToState
  customHitTest : Function
In addition to a normal call to hitTest(), a custom function may impose additional rules that determine if the target should change state.
TouchToState
  downState : String
The value for the "down" state.
TouchToState
  hoverState : String
The value for the "hover" state.
TouchToState
  isEnabled : Boolean
May be set to false to disable the state changes temporarily until set back to true.
TouchToState
  keepDownStateOnRollOut : Boolean
If true, the button state will remain as downState until TouchPhase.ENDED.
TouchToState
  target : DisplayObject
The target component that should change state based on touch phases.
TouchToState
  upState : String
The value for the "up" state.
TouchToState
Public Methods
 MethodDefined By
  
TouchToState(target:DisplayObject = null, callback:Function = null)
Constructor.
TouchToState
Property Detail
callbackproperty
callback:Function

The function to call when the state is changed.

The callback is expected to have the following signature:

function(currentState:String):void


Implementation
    public function get callback():Function
    public function set callback(value:Function):void
currentStateproperty 
currentState:String  [read-only]

The current state of the utility. May be different than the state of the target.


Implementation
    public function get currentState():String
customHitTestproperty 
customHitTest:Function

In addition to a normal call to hitTest(), a custom function may impose additional rules that determine if the target should change state. Called on TouchPhase.BEGAN.

The function must have the following signature:

function(localPosition:Point):Boolean;

The function should return true if the target should be triggered, and false if it should not be triggered.


Implementation
    public function get customHitTest():Function
    public function set customHitTest(value:Function):void
downStateproperty 
downState:String

The value for the "down" state.

The default value is feathers.controls.ButtonState.DOWN.


Implementation
    public function get downState():String
    public function set downState(value:String):void
hoverStateproperty 
hoverState:String

The value for the "hover" state.

The default value is feathers.controls.ButtonState.HOVER.


Implementation
    public function get hoverState():String
    public function set hoverState(value:String):void
isEnabledproperty 
isEnabled:Boolean

May be set to false to disable the state changes temporarily until set back to true.


Implementation
    public function get isEnabled():Boolean
    public function set isEnabled(value:Boolean):void
keepDownStateOnRollOutproperty 
keepDownStateOnRollOut:Boolean

If true, the button state will remain as downState until TouchPhase.ENDED. If false, and the touch leaves the bounds of the button after TouchPhase.BEGAN, the button state will change to upState.

The default value is false.


Implementation
    public function get keepDownStateOnRollOut():Boolean
    public function set keepDownStateOnRollOut(value:Boolean):void
targetproperty 
target:DisplayObject

The target component that should change state based on touch phases.


Implementation
    public function get target():DisplayObject
    public function set target(value:DisplayObject):void
upStateproperty 
upState:String

The value for the "up" state.

The default value is feathers.controls.ButtonState.UP.


Implementation
    public function get upState():String
    public function set upState(value:String):void
Constructor Detail
TouchToState()Constructor
public function TouchToState(target:DisplayObject = null, callback:Function = null)

Constructor.

Parameters
target:DisplayObject (default = null)
 
callback:Function (default = null)