Package | com.eqsim.components |
Class | public class ButtonToggle |
Inheritance | ButtonToggle ![]() |
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 positiononUnset
- Generated when button goes from down to up positiononDisabled
- 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
.
Property | Defined 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 |
Property | Defined 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 |
Method | Defined 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 |
Method | Defined By | ||
---|---|---|---|
changeDownSkin():void
Replace the down (set) skin with defaultButtonDownClassName. | ButtonToggle | ||
changeUpSkin():void
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 |
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 |
_defaultButtonDownClassName | property |
protected var _defaultButtonDownClassName:String = ButtonToggleDefaultDown
_defaultButtonUpClassName | property |
protected var _defaultButtonUpClassName:String = ButtonToggleDefaultUp
_isDownNow | property |
protected var _isDownNow:Boolean = false
_showHand | property |
protected var _showHand:Boolean = true
butDownSkin | property |
protected var butDownSkin:Sprite
Holds the down (set position) skin Sprite.
buttonContainer | property |
protected var buttonContainer:Sprite
Container enclosing the up and down skins, for scaling purposes.
buttonSet | property |
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)
.
public function get buttonSet():Boolean
public function set buttonSet(value:Boolean):void
butUpSkin | property |
protected var butUpSkin:Sprite
Holds the up (unset position) skin Sprite.
defaultButtonDownClassName | property |
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.
public function get defaultButtonDownClassName():String
public function set defaultButtonDownClassName(value:String):void
defaultButtonUpClassName | property |
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.
public function get defaultButtonUpClassName():String
public function set defaultButtonUpClassName(value:String):void
evtDisabled | property |
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.
evtSet | property |
public var evtSet:String = onSet
Event name for when button is put in the set (down) position. Change this value at any time.
evtUnset | property |
public var evtUnset:String = onUnset
Event name for when button is put in the unset (up) position. Change this value at any time.
showHand | property |
showHand:Boolean
Boolean property indicating whether or not to display the hand cursor when the cursor is over this component.
public function get showHand():Boolean
public function set showHand(value:Boolean):void
ButtonToggle | () | Constructor |
public function ButtonToggle()
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 |
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.