Packagecom.eqsim.components
Classpublic class ButtonToggle
InheritanceButtonToggle Inheritance fl.core.UIComponent

This class implements a simple toggle button. Users can change the appearance by setting the class names for defaultButtonUpClassName and defaultButtonUpClassName properties.

The class has three events, by default called:

  • onSet - Generated when button goes from up to down position
  • onUnset - Generated when button goes from down to up position
  • onDisabled - Generated if the user does any operation above (except ReleaseOutside) when the button is disabled (i.e., enabled == false)
  • The events have no data associated with them, except in the case of the onDisabled event: its data is a String indicating the type is the event that would have been invoked, i.e., onPress, onRelease, etc. If one registers for onDisabled, the caller will receive notices for all the events, since the user is subscribing to the onDisabled event.

    The event names can be changed (if desired) in the component property inspector or programmatically via evtSet, evtUnset, and evtDisabled.



    Public Properties
     PropertyDefined By
      buttonSet : Boolean
    Whether the button is in the down (set) or up (unset) position.
    ButtonToggle
      defaultButtonDownClassName : String
    Property for changing the graphics (skin) of the button's down (pressed) state The default skin (value) for this property is ButtonToggleDefaultDown.
    ButtonToggle
      defaultButtonUpClassName : String
    Property for changing the graphics (skin) of the button's up (unpressed) state.
    ButtonToggle
      evtDisabled : String = onDisabled
    Event name of disabled event (when button clicked but button has enabled == false).
    ButtonToggle
      evtSet : String = onSet
    Event name for when button is put in the set (down) position.
    ButtonToggle
      evtUnset : String = onUnset
    Event name for when button is put in the unset (up) position.
    ButtonToggle
      showHand : Boolean
    Boolean property indicating whether or not to display the hand cursor when the cursor is over this component.
    ButtonToggle
    Protected Properties
     PropertyDefined By
      butDownSkin : Sprite
    Holds the down (set position) skin Sprite.
    ButtonToggle
      buttonContainer : Sprite
    Container enclosing the up and down skins, for scaling purposes.
    ButtonToggle
      butUpSkin : Sprite
    Holds the up (unset position) skin Sprite.
    ButtonToggle
      _defaultButtonDownClassName : String = ButtonToggleDefaultDown
    ButtonToggle
      _defaultButtonUpClassName : String = ButtonToggleDefaultUp
    ButtonToggle
      _isDownNow : Boolean = false
    ButtonToggle
      _showHand : Boolean = true
    ButtonToggle
    Public Methods
     MethodDefined By
      
    ButtonToggle
      
    destroy():void
    Removes any listeners or memory allocated for this component.
    ButtonToggle
      
    execEvent(evtName:String, evtVal:* = null, q:Boolean = false):void
    This method is used to programmatically invoke an action of the component based on the event passed in.
    ButtonToggle
      
    onSet(q:Boolean = false):void
    Put the button in the set (down) position and generate the onSet event (if q [quietly] is false [default] -- true suppresses event generation).
    ButtonToggle
      
    onUnset(q:Boolean = false):void
    Put the button in the unset (up) position and generate the onUnset event (if q [quietly] is false [default] -- true suppresses event generation).
    ButtonToggle
    Protected Methods
     MethodDefined By
      
    Replace the down (set) skin with defaultButtonDownClassName.
    ButtonToggle
      
    Replace the up (unset) skin with defaultButtonUpClassName.
    ButtonToggle
      
    configUI():void
    [override] configUI Get the display objects created in preparation of launch.
    ButtonToggle
      
    disabled(val:String, q:Boolean = false):void
    Generate the disabled event.
    ButtonToggle
      
    draw():void
    [override]
    ButtonToggle
      
    generateEvent(type:String, q:Boolean):void
    Generate the given event.
    ButtonToggle
      
    mouseDown(me:MouseEvent):void
    On a mouse click, determine whether to put the button in the up (unset) position or down (set) position.
    ButtonToggle
      
    setDown(buttonState:Boolean):void
    Sets the graphics to the appropriate visual state, up or down
    ButtonToggle
    Events
     Event Summary Defined By
      Event generated when component is inactive (enabled == false) and any other event (set, unset, etc.) would have been invoked.ButtonToggle
      Event generated when button goes from the up (unset) to down (set) position.ButtonToggle
      Event generated when button goes from the down (set) to up (unset) position.ButtonToggle
    Property Detail
    _defaultButtonDownClassNameproperty
    protected var _defaultButtonDownClassName:String = ButtonToggleDefaultDown

    _defaultButtonUpClassNameproperty 
    protected var _defaultButtonUpClassName:String = ButtonToggleDefaultUp

    _isDownNowproperty 
    protected var _isDownNow:Boolean = false

    _showHandproperty 
    protected var _showHand:Boolean = true

    butDownSkinproperty 
    protected var butDownSkin:Sprite

    Holds the down (set position) skin Sprite.

    buttonContainerproperty 
    protected var buttonContainer:Sprite

    Container enclosing the up and down skins, for scaling purposes.

    buttonSetproperty 
    buttonSet:Boolean

    Whether the button is in the down (set) or up (unset) position. Set (down) is true, up is false. Setting this value generates an onSet or an onUnset event. If you do not want to generate the event, use onSet(true) or onUnset(true).


    Implementation
        public function get buttonSet():Boolean
        public function set buttonSet(value:Boolean):void
    butUpSkinproperty 
    protected var butUpSkin:Sprite

    Holds the up (unset position) skin Sprite.

    defaultButtonDownClassNameproperty 
    defaultButtonDownClassName:String

    Property for changing the graphics (skin) of the button's down (pressed) state The default skin (value) for this property is ButtonToggleDefaultDown. To change it, create a class and enter the name here.


    Implementation
        public function get defaultButtonDownClassName():String
        public function set defaultButtonDownClassName(value:String):void
    defaultButtonUpClassNameproperty 
    defaultButtonUpClassName:String

    Property for changing the graphics (skin) of the button's up (unpressed) state. The default skin (value) for this property is ButtonToggleDefaultUp. To change it, create a class and enter the name here.


    Implementation
        public function get defaultButtonUpClassName():String
        public function set defaultButtonUpClassName(value:String):void
    evtDisabledproperty 
    public var evtDisabled:String = onDisabled

    Event name of disabled event (when button clicked but button has enabled == false). The event names should really only be set at the time the component is instantiated (either at run-time, or programmatically). However, you can change it at any time programmatically and the component will use that event name.

    evtSetproperty 
    public var evtSet:String = onSet

    Event name for when button is put in the set (down) position. Change this value at any time.

    evtUnsetproperty 
    public var evtUnset:String = onUnset

    Event name for when button is put in the unset (up) position. Change this value at any time.

    showHandproperty 
    showHand:Boolean

    Boolean property indicating whether or not to display the hand cursor when the cursor is over this component.


    Implementation
        public function get showHand():Boolean
        public function set showHand(value:Boolean):void
    Constructor Detail
    ButtonToggle()Constructor
    public function ButtonToggle()

    Method Detail
    changeDownSkin()method
    protected function changeDownSkin():void

    Replace the down (set) skin with defaultButtonDownClassName.

    changeUpSkin()method 
    protected function changeUpSkin():void

    Replace the up (unset) skin with defaultButtonUpClassName.

    configUI()method 
    override protected function configUI():void

    configUI Get the display objects created in preparation of launch. Note that we get called before our constructor, before strings and before we are notified that we are on the stage!

    destroy()method 
    public function destroy():void

    Removes any listeners or memory allocated for this component.

    disabled()method 
    protected function disabled(val:String, q:Boolean = false):void

    Generate the disabled event.

    Parameters

    val:String
     
    q:Boolean (default = false)

    draw()method 
    override protected function draw():void

    execEvent()method 
    public function execEvent(evtName:String, evtVal:* = null, q:Boolean = false):void

    This method is used to programmatically invoke an action of the component based on the event passed in. When a user invokes an action, like presses a button, the button generates an onPress event. This method does the opposite -- given an onPress event, this the method visually depresses the button. This is typically used to simulate the user invoking the action.

    Parameters

    evtName:String — Event name (string) must match the event this component generates
     
    evtVal:* (default = null) — Event value (for button, this value is ignored)
     
    q:Boolean (default = false) — Boolean true to invoke action without generating the event, false or not given at all to allow event to be generated

    generateEvent()method 
    protected function generateEvent(type:String, q:Boolean):void

    Generate the given event.

    Parameters

    type:String — event type
     
    q:Boolean — A 'quiet' parameter. If true, do not generate the event. Defaults to false.

    mouseDown()method 
    protected function mouseDown(me:MouseEvent):void

    On a mouse click, determine whether to put the button in the up (unset) position or down (set) position.

    Parameters

    me:MouseEvent

    onSet()method 
    public function onSet(q:Boolean = false):void

    Put the button in the set (down) position and generate the onSet event (if q [quietly] is false [default] -- true suppresses event generation).

    Parameters

    q:Boolean (default = false)

    onUnset()method 
    public function onUnset(q:Boolean = false):void

    Put the button in the unset (up) position and generate the onUnset event (if q [quietly] is false [default] -- true suppresses event generation).

    Parameters

    q:Boolean (default = false)

    setDown()method 
    protected function setDown(buttonState:Boolean):void

    Sets the graphics to the appropriate visual state, up or down

    Parameters

    buttonState:Boolean

    Event Detail
    onDisabled Event

    Event generated when component is inactive (enabled == false) and any other event (set, unset, etc.) would have been invoked. Event value data gives the string of which event would have been triggered.

    onSet Event  

    Event generated when button goes from the up (unset) to down (set) position.

    onUnset Event  

    Event generated when button goes from the down (set) to up (unset) position.