Packagecom.gestureworks.cml.element
Classpublic class Button
InheritanceButton Inheritance Container Inheritance ContainerFactory Inheritance ElementFactory Inheritance flash.display.Sprite
Subclasses ButtonElement, Key

The Button hides or shows DisplayObjects on specified state events. The available button states are exclusive touch states, exclusive mouse states, and auto-states. Mouse states are triggered by 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;
        }
     



Public Properties
 PropertyDefined By
 Inheritedalpha : Number
[override] [write-only] sets the alpha for display objects
ElementFactory
 Inheritedblur : Boolean
Sets the drop shadow effect
ElementFactory
 Inheritedbottom : Number
sets the bottom value
ElementFactory
 InheritedchildList : ChildList
[read-only] store the child list
ContainerFactory
 Inheritedclass_ : String
Object's css class;
ElementFactory
 InheritedclassName : String
sets the class name of displayobject
ElementFactory
 InheritedcmlIndex : int
sets the cml index
ElementFactory
  debug : Boolean = false
Button
 InheriteddebugStyle : *
sets the debug style
ElementFactory
 InheriteddimensionsTo : String
sets the dimensions of the container
ContainerFactory
  dispatch : String
Assigns a message to dispatch with a button state event.
Button
  dispatchDefault : Boolean = false
Button
 InheriteddisplayEvents : String
Use for dispatch completes.
ElementFactory
  down : *
Sets button state association with down event
Button
 InheriteddropShadow : Boolean
Sets the drop shadow effect
ElementFactory
 Inheritedheight : Number
[override] Sets width of the display object in pixels
ElementFactory
 InheritedheightPercent : String
sets the height percent of display object
ElementFactory
  hit : *
The hit object is the object recieving the input events
Button
 InheritedhorizontalCenter : Number
sets the horizontal center of display object
ElementFactory
 Inheritedid : String
sets the id of child
ElementFactory
 Inheritedindex : int
sets the index of display object
ElementFactory
 InheritedinfoSource : String
sets info source
ContainerFactory
  initial : *
Sets the initial button state object
Button
 Inheritedlayout : *
Sets the layout of the container
Container
 InheritedlayoutComplete : Function
Sets the function to call when the layout is complete
Container
 InheritedlayoutList : Dictionary
Defines the layoutlist
Container
 InheritedlayoutUpdate : Function
Sets the function to call when the layout updates
Container
 Inheritedleft : Number
sets left value
ElementFactory
  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
 InheritedpaddingBottom : Number
Sets the number of pixels between the container's bottom border and the bottom of its content area.
Container
 InheritedpaddingLeft : Number
Sets the number of pixels between the component's left border and the left edge of its content area.
Container
 InheritedpaddingRight : Number
Sets the number of pixels between the component's right border and the right edge of its content area.
Container
 InheritedpaddingTop : Number
Sets the number of pixels between the container's top border and the top of its content area.
Container
 Inheritedposition : String
Sets the position
Container
 InheritedpropertyStates : Array
Deprecated: Please Use state
ElementFactory
 Inheritedright : Number
sets the right value
ElementFactory
 Inheritedscale : Number
Sets both the x and y scale values
ElementFactory
 InheritedscaleX : Number
[override] Sets width of the display object in pixels
ElementFactory
 InheritedscaleY : Number
[override] Sets width of the display object in pixels
ElementFactory
  side : String
Attaches an event string to a button to listen for to toggle visibility when that event is dispatched.
Button
 Inheritedstate : Array
property states array
ElementFactory
  tap : *
Sets the button state association with tap event.
Button
  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
 Inheritedtop : Number
sets top value
ElementFactory
  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
 InheritedverticalCenter : Number
sets the vertical center of display object
ElementFactory
 Inheritedwidth : Number
[override] Sets width of the display object in pixels
ElementFactory
 InheritedwidthPercent : String
sets the percent of width of display object
ElementFactory
Protected Properties
 PropertyDefined By
  buttonStates : Array
Button
Public Methods
 MethodDefined By
  
Contructor
Button
 Inherited
This method searches the childlist and add the children
ContainerFactory
 Inherited
addChild(child:DisplayObject):DisplayObject
[override] Adds child to display list and, if not already added, the child list TODO: This mechanism should be abstracted to better syncrhonize child and display lists
Container
 Inherited
applyLayout(value:* = null):void
Apply the containers layout
Container
 Inherited
childToList(id:String, child:*):void
this method append to the childlist
ContainerFactory
  
clone():*
[override] Returns clone of self
Button
  
[override]
Button
  
dispose():void
[override] Destructor
Button
 Inherited
getIndex(index:int):*
returns childlist index
Container
 Inherited
getKey(key:String):*
returns the childlist key
Container
 Inherited
hideIndex(index:int):void
hides the childlist index
Container
 Inherited
hideKey(key:String):void
hides the childlist key
Container
  
init():void
[override] Initialization function
Button
  
Button
 Inherited
parseCML(cml:XMLList):XMLList
[override] Parse cml for local layouts.
Container
 Inherited
postparseCML(cml:XMLList):void
post parses the cml file
ElementFactory
  
reset():void
Button
  
runToggle():void
Button
 Inherited
searchChildren(value:*, returnType:Class = null):*
This method does a depth first search of childLists.
Container
 Inherited
This method sets the dimensions of childlist
ContainerFactory
 Inherited
showIndex(index:int):void
shows the childlist index
Container
 Inherited
showKey(key:String):void
shows the childlist key
Container
  
Updates dimensions
Button
 Inherited
updateProperties(state:Number = 0):void
this method updates the properties
ElementFactory
Protected Methods
 MethodDefined 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
  
onTouchDown(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
Property Detail
buttonStatesproperty
protected var buttonStates:Array

debugproperty 
public var debug:Boolean = false

dispatchproperty 
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").


Implementation
    public function get dispatch():String
    public function set dispatch(value:String):void
dispatchDefaultproperty 
public var dispatchDefault:Boolean = false

downproperty 
down:*

Sets button state association with down event


Implementation
    public function get down():*
    public function set down(value:any):void
hitproperty 
hit:*

The hit object is the object recieving the input events


Implementation
    public function get hit():*
    public function set hit(value:any):void
initialproperty 
initial:*

Sets the initial button state object


Implementation
    public function get initial():*
    public function set initial(value:any):void
mouseDownproperty 
mouseDown:*

Sets button state association with mouse down event


Implementation
    public function get mouseDown():*
    public function set mouseDown(value:any):void
mouseOutproperty 
mouseOut:*

Sets button state association with mouse out event


Implementation
    public function get mouseOut():*
    public function set mouseOut(value:any):void
mouseOverproperty 
mouseOver:*

Sets button state association with mouse over event


Implementation
    public function get mouseOver():*
    public function set mouseOver(value:any):void
mouseUpproperty 
mouseUp:*

Sets button state association with mouse up event


Implementation
    public function get mouseUp():*
    public function set mouseUp(value:any):void
outproperty 
out:*

Sets button state association with out event


Implementation
    public function get out():*
    public function set out(value:any):void
overproperty 
over:*

Sets button state association with over event (mouse only)


Implementation
    public function get over():*
    public function set over(value:any):void
sideproperty 
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.


Implementation
    public function get side():String
    public function set side(value:String):void
tapproperty 
tap:*

Sets the button state association with tap event.


Implementation
    public function get tap():*
    public function set tap(value:any):void
toggleproperty 
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.


Implementation
    public function get toggle():String
    public function set toggle(value:String):void
touchDownproperty 
touchDown:*

Sets button state association with touch down event


Implementation
    public function get touchDown():*
    public function set touchDown(value:any):void
touchOutproperty 
touchOut:*

Sets button state association with touch out event


Implementation
    public function get touchOut():*
    public function set touchOut(value:any):void
touchOverproperty 
touchOver:*

Sets button state association with touch out event


Implementation
    public function get touchOver():*
    public function set touchOver(value:any):void
touchUpproperty 
touchUp:*

Sets button state association with touch up event


Implementation
    public function get touchUp():*
    public function set touchUp(value:any):void
upproperty 
up:*

Sets button state association with up event


Implementation
    public function get up():*
    public function set up(value:any):void
Constructor Detail
Button()Constructor
public function Button()

Contructor

Method Detail
clone()method
override public function clone():*

Returns clone of self

Returns
*
displayComplete()method 
override public function displayComplete():void

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 
public function onFlip(e:StateEvent):void

Parameters

e:StateEvent

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:*

onTouchDown()method 
protected function onTouchDown(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