Package | com.gestureworks.cml.elements |
Class | public class Button |
Inheritance | Button ![]() ![]() ![]() |
Subclasses | Key |
MouseEvent
events and touch states are triggered by TuioTouchEvent
and TouchEvent
event types. Auto-states
automate the registration of event types based on system properties.
var button:Button = new Button(); button.x = 750; button.y = 200; button.dispatch = "initial:initial:down:down:up:up:over:over:out:out"; button.addEventListener(StateEvent.CHANGE, buttonState); //assign a different color to each button state button.hit = getCircle(0x000000, 0);; //hit area button.initial = getCircle(0xFFFFFF); //white button.down = getCircle(0x0000FF); //blue button.up = getCircle(0xFF0000); //red button.over = getCircle(0x00FF00); //green button.out = getCircle(0xFF00FF); //purple button.init(); addChild(button); //displays the current button state text = new Text(); text.x = 810; text.y = 420; text.text = "initial"; text.autoSize = "center"; text.fontSize = 50; text.textColor = 0xFFFFFF; addChild(text); function getCircle(color:uint, alpha:Number = 1):Graphic { var circle:Graphic = new Graphic(); circle.shape = "circle"; circle.radius = 100; circle.color = color; circle.alpha = alpha; circle.lineStroke = 0; return circle; } function buttonState(e:StateEvent):void { text.text = e.value; }
Property | Defined By | ||
---|---|---|---|
![]() | autoShuffle : Boolean
autoshuffles
| TouchContainer | |
![]() | childList : ChildList
Returns the object's childList. | TouchContainer | |
![]() | className : String
sets the class name of displayobject
| TouchContainer | |
![]() | cloneExclusions : Vector.<String> [read-only]
Returns a list of properties to exclude when cloning this object
| TouchContainer | |
![]() | cmlIndex : int
Returns the index created by the CML parser. | TouchContainer | |
debug : Boolean = false | Button | ||
![]() | dimensionsTo : Object
Sets the dimensions of TouchContainer to given object
| TouchContainer | |
dispatch : String
Assigns a message to dispatch with a button state event. | Button | ||
dispatchDefault : Boolean = false | Button | ||
down : *
Sets button state association with down event
| Button | ||
![]() | dropShadow : Boolean
Sets the drop shadow effect
| TouchContainer | |
![]() | group : String | TouchContainer | |
![]() | height : Number [override]
sets the height of the container
| TouchContainer | |
![]() | heightPercent : Number
sets the height of the container
| TouchContainer | |
hideOnToggle : Boolean
Specifies whether buttons will hide on a toggle event. | Button | ||
hit : *
The hit object is the object recieving the input events
| Button | ||
![]() | id : String
Returns the object's id. | TouchContainer | |
initial : *
Sets the initial button state object
| Button | ||
![]() | layout : *
specifies the type of layout
| TouchContainer | |
![]() | layoutList : Dictionary | TouchContainer | |
![]() | mouseChildren : Boolean [override]
sets the mousechildren value to true or false. | TouchContainer | |
mouseDown : *
Sets button state association with mouse down event
| Button | ||
mouseOut : *
Sets button state association with mouse out event
| Button | ||
mouseOver : *
Sets button state association with mouse over event
| Button | ||
mouseUp : *
Sets button state association with mouse up event
| Button | ||
out : *
Sets button state association with out event
| Button | ||
over : *
Sets button state association with over event (mouse only)
| Button | ||
![]() | paddingBottom : Number
Sets the number of pixels between the container's bottom border and the bottom of its content area. | TouchContainer | |
![]() | paddingLeft : Number
Sets the number of pixels between the component's left border and the left edge of its content area. | TouchContainer | |
![]() | paddingRight : Number
Sets the number of pixels between the component's right border and the right edge of its content area. | TouchContainer | |
![]() | paddingTop : Number
Sets the number of pixels between the container's top border and the top of its content area. | TouchContainer | |
![]() | position : *
Sets the position
| TouchContainer | |
![]() | relativeX : Boolean
When set true this containers children's x position will be laid out relatively
to each other. | TouchContainer | |
![]() | relativeY : Boolean
When set true this containers children's y position will be laid out relatively
to each other. | TouchContainer | |
side : String
Attaches an event string to a button to listen for to toggle visibility when that event is dispatched. | Button | ||
![]() | sound : String | TouchContainer | |
![]() | state : Dictionary | TouchContainer | |
![]() | stateId : *
Returns the current state id. | TouchContainer | |
tap : *
Sets the button state association with tap event. | Button | ||
![]() | toBitmap : Boolean | TouchContainer | |
toggle : String
An alternative to button state events, the toggle displays the next child at each event defined by the
toggle value (e.g. | Button | ||
touchDown : *
Sets button state association with touch down event
| Button | ||
touchOut : *
Sets button state association with touch out event
| Button | ||
touchOver : *
Sets button state association with touch out event
| Button | ||
touchUp : *
Sets button state association with touch up event
| Button | ||
up : *
Sets button state association with up event
| Button | ||
![]() | width : Number [override]
sets the width of the container
| TouchContainer | |
![]() | widthPercent : Number
sets the width of the container
| TouchContainer |
Property | Defined By | ||
---|---|---|---|
buttonStates : Array | Button | ||
![]() | cmlGestureList : Object | TouchContainer |
Method | Defined By | ||
---|---|---|---|
Button()
Contructor
| Button | ||
![]() | activateTouch():void | TouchContainer | |
![]() | addAllChildren():void
method searches the child and adds to the list
| TouchContainer | |
![]() | addChild(child:DisplayObject):DisplayObject [override]
Adds child to display list and, if not already added, the child list
| TouchContainer | |
![]() | addChildAt(child:DisplayObject, index:int):DisplayObject [override]
Adds child to display list and, if not already added, the child list
| TouchContainer | |
![]() | applyLayout(value:* = null):void
Apply the containers layout
| TouchContainer | |
![]() | childToList(id:String, child:*):void
child appended to the childlist
| TouchContainer | |
clone():* [override]
Returns clone of self
| Button | ||
dispose():void [override]
Destructor
| Button | ||
![]() | getElementById(id:String):*
Searches CML childList by id. | TouchContainer | |
![]() | getElementsByClassName(className:String):Array
Searches the CML childList by className. | TouchContainer | |
![]() | getElementsByTagName(tagName:Class):Array
Searches the CML childList by tagName as Class. | TouchContainer | |
init():void [override]
Initialization function
| Button | ||
![]() | loadState(sId:* = null, recursion:Boolean = false):void
Loads state by index number. | TouchContainer | |
![]() | makeGestureList(value:XMLList):Object
Creates gestureList object from XML
| TouchContainer | |
onFlip(e:StateEvent):void | Button | ||
![]() | parseCML(cml:XMLList):XMLList
Parse cml for local layouts. | TouchContainer | |
![]() | postparseCML(cml:XMLList):void
Abstract method allows the setting of a postparse CML routine. | TouchContainer | |
![]() | querySelector(selector:String):*
Searches the CML childList by selector. | TouchContainer | |
![]() | querySelectorAll(selector:*):Array
Search the CML childList by selector. | TouchContainer | |
![]() | removeChild(child:DisplayObject):DisplayObject [override]
Removes child from display list and, if not already removed, the child list
| TouchContainer | |
![]() | removeChildAt(index:int):DisplayObject [override]
Removes child from display list and, if not already removed, the child list
| TouchContainer | |
![]() | removeChildren(beginIndex:int = 0, endIndex:int = 2147483647):void [override]
Removes children from display list and, if not already removed, the child list
| TouchContainer | |
reset():void | Button | ||
runToggle():void | Button | ||
![]() | saveState(sId:* = null, recursion:Boolean = false):void
Save state by index number. | TouchContainer | |
![]() | searchChildren(value:*, returnType:Class = null):*
This method does a depth first search of childLists. | TouchContainer | |
![]() | setDimensionsToChild():void
method sets the dimensions of each child
| TouchContainer | |
![]() | tweenState(sId:* = null, tweenTime:Number = 1):void
Tween state by stateIndex from current to given state index. | TouchContainer | |
updateLayout():void
Updates dimensions
| Button | ||
![]() | updatePadding():void
Updates child padding within this container
| TouchContainer | |
![]() | updatePercentDim():void
Updates child percent dimensions within this container
| TouchContainer | |
![]() | updateProperties(state:* = 0):void
Updates properties from state. | TouchContainer | |
![]() | updateRelativePos():void
Updates child relative positions within this container
| TouchContainer |
Method | Defined By | ||
---|---|---|---|
onDown(event:*):void
Processes the down event by displaying the down state and hiding the other states. | Button | ||
onMouseDown(event:*):void
Processes the mouse down event by displaying the mouseDown state and hiding the other states. | Button | ||
onMouseOut(event:*):void
Processes the mouse out event by displaying the mouseOut state and hiding the other states. | Button | ||
onMouseOver(event:*):void
Processes the mouse over event by displaying the mouseOver state and hiding the other states. | Button | ||
onMouseUp(event:*):void
Processes the mouse up event by displaying the mouseUp state and hiding the other states. | Button | ||
onOut(event:*):void
Processes the out event by displaying the out state and hiding the other states. | Button | ||
onOver(event:*):void
Processes the over event by displaying the over state and hiding the other states. | Button | ||
onTap(event:*):void | Button | ||
onToggle(event:*):void
Displays the the next child on the specified button event. | Button | ||
onTouchBegin(event:*):void
Processes the touch down event by displaying the touchDown state and hiding the other states. | Button | ||
onTouchOut(event:*):void
Processes the touch out event by displaying the touchOut state and hiding the other states. | Button | ||
onTouchOver(event:*):void
Processes the touch over event by displaying the touchOver state and hiding the other states. | Button | ||
onTouchUp(event:*):void
Processes the touch up event by displaying the touchUp state and hiding the other states. | Button | ||
onUp(event:*):void
Processes the down event by displaying the up state and hiding the other states. | Button |
buttonStates | property |
protected var buttonStates:Array
debug | property |
public var debug:Boolean = false
dispatch | property |
dispatch:String
Assigns a message to dispatch with a button state event. The value is a colon-delimited string defining events and associated messages (e.g. "down:button is down:up:button is up").
public function get dispatch():String
public function set dispatch(value:String):void
dispatchDefault | property |
public var dispatchDefault:Boolean = false
down | property |
down:*
Sets button state association with down event
public function get down():*
public function set down(value:any):void
hideOnToggle | property |
hideOnToggle:Boolean
Specifies whether buttons will hide on a toggle event.
public function get hideOnToggle():Boolean
public function set hideOnToggle(value:Boolean):void
hit | property |
hit:*
The hit object is the object recieving the input events
public function get hit():*
public function set hit(value:any):void
initial | property |
initial:*
Sets the initial button state object
public function get initial():*
public function set initial(value:any):void
mouseDown | property |
mouseDown:*
Sets button state association with mouse down event
public function get mouseDown():*
public function set mouseDown(value:any):void
mouseOut | property |
mouseOut:*
Sets button state association with mouse out event
public function get mouseOut():*
public function set mouseOut(value:any):void
mouseOver | property |
mouseOver:*
Sets button state association with mouse over event
public function get mouseOver():*
public function set mouseOver(value:any):void
mouseUp | property |
mouseUp:*
Sets button state association with mouse up event
public function get mouseUp():*
public function set mouseUp(value:any):void
out | property |
out:*
Sets button state association with out event
public function get out():*
public function set out(value:any):void
over | property |
over:*
Sets button state association with over event (mouse only)
public function get over():*
public function set over(value:any):void
side | property |
side:String
Attaches an event string to a button to listen for to toggle visibility when that event is dispatched. For example, setting side="info" and visible="false" will mean that the button will only be visible when the info button is toggled, as the visible state will simply be reversed from whatever it is.
public function get side():String
public function set side(value:String):void
tap | property |
tap:*
Sets the button state association with tap event.
public function get tap():*
public function set tap(value:any):void
toggle | property |
toggle:String
An alternative to button state events, the toggle displays the next child at each event defined by the
toggle
value (e.g. toggle="up" or toggle="mouseDown"). Setting the toggle value bypasses the
button state events. The original intention of the toggle mechanism, was to allow a button element to house
multiple button elements and toggle between them without interfering with their individual states.
public function get toggle():String
public function set toggle(value:String):void
touchDown | property |
touchDown:*
Sets button state association with touch down event
public function get touchDown():*
public function set touchDown(value:any):void
touchOut | property |
touchOut:*
Sets button state association with touch out event
public function get touchOut():*
public function set touchOut(value:any):void
touchOver | property |
touchOver:*
Sets button state association with touch out event
public function get touchOver():*
public function set touchOver(value:any):void
touchUp | property |
touchUp:*
Sets button state association with touch up event
public function get touchUp():*
public function set touchUp(value:any):void
up | property |
up:*
Sets button state association with up event
public function get up():*
public function set up(value:any):void
Button | () | Constructor |
public function Button()
Contructor
clone | () | method |
override public function clone():*
Returns clone of self
Returns* |
dispose | () | method |
override public function dispose():void
Destructor
init | () | method |
override public function init():void
Initialization function
onDown | () | method |
protected function onDown(event:*):void
Processes the down event by displaying the down state and hiding the other states. Enables and disables appropriate listeners to control event flow.
Parameters
event:* — the down event
|
onFlip | () | method |
onMouseDown | () | method |
protected function onMouseDown(event:*):void
Processes the mouse down event by displaying the mouseDown state and hiding the other states. Enables and disables appropriate listeners to control event flow.
Parameters
event:* — the mouse down event
|
onMouseOut | () | method |
protected function onMouseOut(event:*):void
Processes the mouse out event by displaying the mouseOut state and hiding the other states. Enables and disables appropriate listeners to control event flow.
Parameters
event:* — the mouse out event
|
onMouseOver | () | method |
protected function onMouseOver(event:*):void
Processes the mouse over event by displaying the mouseOver state and hiding the other states. Enables and disables appropriate listeners to control event flow.
Parameters
event:* — the mouse over event
|
onMouseUp | () | method |
protected function onMouseUp(event:*):void
Processes the mouse up event by displaying the mouseUp state and hiding the other states. Enables and disables appropriate listeners to control event flow.
Parameters
event:* — the mouse up event
|
onOut | () | method |
protected function onOut(event:*):void
Processes the out event by displaying the out state and hiding the other states. Enables and disables appropriate listeners to control event flow.
Parameters
event:* — the out event
|
onOver | () | method |
protected function onOver(event:*):void
Processes the over event by displaying the over state and hiding the other states. Enables and disables appropriate listeners to control event flow.
Parameters
event:* — the over event
|
onTap | () | method |
protected function onTap(event:*):void
Parameters
event:* |
onToggle | () | method |
protected function onToggle(event:*):void
Displays the the next child on the specified button event. If toggle is used, the button states are ignored.
Parameters
event:* |
onTouchBegin | () | method |
protected function onTouchBegin(event:*):void
Processes the touch down event by displaying the touchDown state and hiding the other states. Enables and disables appropriate listeners to control event flow.
Parameters
event:* — the touch down event
|
onTouchOut | () | method |
protected function onTouchOut(event:*):void
Processes the touch out event by displaying the touchOut state and hiding the other states. Enables and disables appropriate listeners to control event flow.
Parameters
event:* — the touch out event
|
onTouchOver | () | method |
protected function onTouchOver(event:*):void
Processes the touch over event by displaying the touchOver state and hiding the other states. Enables and disables appropriate listeners to control event flow.
Parameters
event:* — the touch over event
|
onTouchUp | () | method |
protected function onTouchUp(event:*):void
Processes the touch up event by displaying the touchUp state and hiding the other states. Enables and disables appropriate listeners to control event flow.
Parameters
event:* — the touch up event
|
onUp | () | method |
protected function onUp(event:*):void
Processes the down event by displaying the up state and hiding the other states. Enables and disables appropriate listeners to control event flow.
Parameters
event:* — the up event
|
reset | () | method |
public function reset():void
runToggle | () | method |
public function runToggle():void
updateLayout | () | method |
public function updateLayout():void
Updates dimensions