Package | com.eqsim.components |
Class | public class Switch3 |
Inheritance | Switch3 ![]() |
This class implements a simple three position switch.
The switch generates four events: onUp
, onDown
, onMiddle
, and onDisabled
.
The switch has the option of auto-center, meaning it can be made to revert to the middle position after the mouse is
let go while the switch is in the up or down position. The switch graphics are all contained in a MovieClip which
you can change by setting the defaultSwitchClass
property. Look in that property to see more details about what that MovieClip must contain.
Property | Defined By | ||
---|---|---|---|
autoCenter : Boolean
Boolean value indicating whether or not to return to center after mouse click up or down. | Switch3 | ||
defaultSwitchClass : String
Property for changing the graphics (skin) of the switch. | Switch3 | ||
evtDisabled : String = onDisabled
Event name of disabled event (when button clicked but button has enabled == false). | Switch3 | ||
evtDown : String = onDown
Event name for when button is put in the down position. | Switch3 | ||
evtMiddle : String = onMiddle
Event name for when button is put in the middle position. | Switch3 | ||
evtUp : String = onUp
Event name for when button is put in the up position. | Switch3 | ||
position : String
Which position the switch is in -- "up", "middle", or "down". | Switch3 | ||
showHand : Boolean
Boolean property indicating whether or not to display the hand cursor when the cursor is over this component. | Switch3 |
Property | Defined By | ||
---|---|---|---|
_autoCenter : Boolean = false | Switch3 | ||
buttonContainer : Sprite
Overall Sprite container to ease scaling. | Switch3 | ||
_defaultSwitchClass : String = switch3DefaultSkin | Switch3 | ||
_position : String = middle | Switch3 | ||
_showHand : Boolean = true | Switch3 | ||
switchSkin : MovieClip
The MovieClip with the switch skin. | Switch3 |
Method | Defined By | ||
---|---|---|---|
Switch3() | Switch3 | ||
destroy():void | Switch3 | ||
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. | Switch3 | ||
setSwitchPosition(pos:String, q:Boolean = false):void
Set the switch to the "up", "middle", or "down" position programmatically. | Switch3 |
Method | Defined By | ||
---|---|---|---|
changeSkin(n:String):void
Change the switch skin to the given class name. | Switch3 | ||
configUI():void [override]
configUI
Get the display objects created in preparation of launch. | Switch3 | ||
draw():void [override]
| Switch3 | ||
flipToDown(me:MouseEvent, q:Boolean = false):void
Moves switch to down position. | Switch3 | ||
flipToMiddle(me:MouseEvent, q:Boolean = false):void
Moves switch to middle position. | Switch3 | ||
flipToUp(me:MouseEvent, q:Boolean = false):void
Moves switch to up position. | Switch3 | ||
generateEvent(type:String, q:Boolean):void
generates the switch events. | Switch3 | ||
removeListeners():void
Removes listeners. | Switch3 | ||
setupSwitchHandlers():void
Creates the listeners for the up, middle, and down positions. | Switch3 |
Event | Summary | Defined By | ||
---|---|---|---|---|
Event generated when component is inactive (enabled == false) and any other event (onUp, onDown, etc.) would have been invoked. | Switch3 | |||
Event generated when switch put in the down position. | Switch3 | |||
Event generated when switch put in the middle position. | Switch3 | |||
Event generated when switch put in the up position. | Switch3 |
_autoCenter | property |
protected var _autoCenter:Boolean = false
_defaultSwitchClass | property |
protected var _defaultSwitchClass:String = switch3DefaultSkin
_position | property |
protected var _position:String = middle
_showHand | property |
protected var _showHand:Boolean = true
autoCenter | property |
autoCenter:Boolean
Boolean value indicating whether or not to return to center after mouse click up or down. If true
, then there is
no clickable middle position for the switch -- simply releasing the mouse when the switch is in the up or down position
will have the switch return to the middle. A value of false
will make a clickable middle position.
public function get autoCenter():Boolean
public function set autoCenter(value:Boolean):void
buttonContainer | property |
protected var buttonContainer:Sprite
Overall Sprite container to ease scaling.
defaultSwitchClass | property |
defaultSwitchClass:String
Property for changing the graphics (skin) of the switch.
The graphic (MovieClip) must have the following items defined within it:
public function get defaultSwitchClass():String
public function set defaultSwitchClass(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.
evtDown | property |
public var evtDown:String = onDown
Event name for when button is put in the down position.
evtMiddle | property |
public var evtMiddle:String = onMiddle
Event name for when button is put in the middle position.
evtUp | property |
public var evtUp:String = onUp
Event name for when button is put in the up position.
position | property |
position:String
Which position the switch is in -- "up", "middle", or "down".
public function get position():String
public function set position(value:String):void
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
switchSkin | property |
protected var switchSkin:MovieClip
The MovieClip with the switch skin.
Switch3 | () | Constructor |
public function Switch3()
changeSkin | () | method |
protected function changeSkin(n:String):void
Change the switch skin to the given class name.
Parameters
n:String |
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, and before we are notified that we are on the stage!
destroy | () | method |
public function destroy():void
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 the up direction on the switch, the switch generates an onUp event. This method does the opposite -- given an onUp event, this the method visually moves the switch to the up position. 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 (only applicable if the event is onDisabled, in which case this value is evtUp, evtMiddle, or evtDown)
| |
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 (default == false)
|
flipToDown | () | method |
protected function flipToDown(me:MouseEvent, q:Boolean = false):void
Moves switch to down position. If autoCenter is true, setup mechanism to return switch to center when mouse is released.
Parameters
me:MouseEvent | |
q:Boolean (default = false )
|
flipToMiddle | () | method |
protected function flipToMiddle(me:MouseEvent, q:Boolean = false):void
Moves switch to middle position.
Parameters
me:MouseEvent | |
q:Boolean (default = false )
|
flipToUp | () | method |
protected function flipToUp(me:MouseEvent, q:Boolean = false):void
Moves switch to up position. If autoCenter is true, setup mechanism to return switch to center when mouse is released.
Parameters
me:MouseEvent | |
q:Boolean (default = false )
|
generateEvent | () | method |
protected function generateEvent(type:String, q:Boolean):void
generates the switch events.
Parameters
type:String | |
q:Boolean |
removeListeners | () | method |
protected function removeListeners():void
Removes listeners.
setSwitchPosition | () | method |
public function setSwitchPosition(pos:String, q:Boolean = false):void
Set the switch to the "up", "middle", or "down" position programmatically. If enabled == false, the position does not change but the event that would have been triggered is sent as the data object of the onDisabled event.
Parameters
pos:String — Can be "up", "middle", or "down" (case-sensitive)
| |
q:Boolean (default = false ) — If true, don't generate the corresponding event on position change. If false (default), generate the event.
|
setupSwitchHandlers | () | method |
protected function setupSwitchHandlers():void
Creates the listeners for the up, middle, and down positions.
onDisabled | Event |
Event generated when component is inactive (enabled == false) and any other event (onUp, onDown, etc.) would have been invoked.
Event value data
gives the string of which event would have been triggered.
onDown | Event |
Event generated when switch put in the down position.
onMiddle | Event |
Event generated when switch put in the middle position.
onUp | Event |
Event generated when switch put in the up position.