Packageorg.flixel
Classpublic class FlxButton
InheritanceFlxButton Inheritance FlxSprite Inheritance FlxObject Inheritance FlxBasic Inheritance Object

A simple button class that calls a function when clicked by the mouse.



Public Properties
 PropertyDefined By
 Inheritedacceleration : FlxPoint
How fast the speed of this object is changing.
FlxObject
 Inheritedactive : Boolean
Controls whether update() is automatically called by FlxState/FlxGroup.
FlxBasic
 Inherited_ACTIVECOUNT : uint
[static]
FlxBasic
 Inheritedalive : Boolean
Useful state for many game objects - "dead" (!alive) vs alive.
FlxBasic
 InheritedallowCollisions : uint
Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating collision directions.
FlxObject
 Inheritedalpha : Number
Set alpha to a number between 0 and 1 to change the opacity of the sprite.
FlxSprite
 Inheritedangle : Number
Set the angle of a sprite to rotate it.
FlxObject
 InheritedangularAcceleration : Number
How fast the spin speed should change.
FlxObject
 InheritedangularDrag : Number
Like drag but for spinning.
FlxObject
 InheritedangularVelocity : Number
This is how fast you want this sprite to spin.
FlxObject
 Inheritedantialiasing : Boolean
Controls whether the object is smoothed when rotated, affects performance.
FlxSprite
 Inheritedblend : String
Blending modes, just like Photoshop or whatever.
FlxSprite
 Inheritedcameras : Array
An array of camera objects that this object will use during draw().
FlxBasic
 Inheritedcolor : uint
Set color to a number in this format: 0xRRGGBB.
FlxSprite
 Inheriteddirty : Boolean
Set this flag to true to force the sprite to update during the draw() call.
FlxSprite
 Inheriteddrag : FlxPoint
This isn't drag exactly, more like deceleration that is only applied when acceleration is not affecting the sprite.
FlxObject
 Inheritedelasticity : Number
The bounciness of this object.
FlxObject
 Inheritedexists : Boolean
Controls whether update() and draw() are automatically called by FlxState/FlxGroup.
FlxBasic
 Inheritedfacing : uint
Set facing using FlxSprite.LEFT,RIGHT, UP, and DOWN to take advantage of flipped sprites and/or just track player orientation more easily.
FlxSprite
 Inheritedfinished : Boolean
Whether the current animation has finished its first (or only) loop.
FlxSprite
 Inheritedflickering : Boolean
[read-only] Check to see if the object is still flickering.
FlxObject
 Inheritedframe : uint
Tell the sprite to change to a specific frame of animation.
FlxSprite
 InheritedframeHeight : uint
The height of the actual graphic or image being displayed (not necessarily the game object/bounding box).
FlxSprite
 InheritedframePixels : BitmapData
The actual Flash BitmapData object representing the current display state of the sprite.
FlxSprite
 Inheritedframes : uint
The total number of frames in this image.
FlxSprite
 InheritedframeWidth : uint
The width of the actual graphic or image being displayed (not necessarily the game object/bounding box).
FlxSprite
 Inheritedhealth : Number
Handy for storing health percentage or armor points or whatever.
FlxObject
 Inheritedheight : Number
The height of this object.
FlxObject
  HIGHLIGHT : uint = 1
[static] Used with public variable status, means highlighted (usually from mouse over).
FlxButton
 InheritedID : int
IDs seem like they could be pretty useful, huh? They're not actually used for anything yet though.
FlxBasic
 InheritedignoreDrawDebug : Boolean
Setting this to true will prevent the object from appearing when the visual debug mode in the debugger overlay is toggled on.
FlxBasic
 Inheritedimmovable : Boolean
Whether an object will move/alter position after a collision.
FlxObject
  label : FlxText
The text that appears on the button.
FlxButton
  labelOffset : FlxPoint
Controls the offset (from top left) of the text from the button.
FlxButton
 Inheritedlast : FlxPoint
Important variable for collision processing.
FlxObject
 Inheritedmass : Number
The virtual mass of the object.
FlxObject
 InheritedmaxAngular : Number
Use in conjunction with angularAcceleration for fluid spin speed control.
FlxObject
 InheritedmaxVelocity : FlxPoint
If you are using acceleration, you can use maxVelocity with it to cap the speed automatically (very useful!).
FlxObject
 Inheritedmoves : Boolean
Set this to false if you want to skip the automatic motion/movement stuff (see updateMotion()).
FlxObject
  NORMAL : uint = 0
[static] Used with public variable status, means not highlighted or pressed.
FlxButton
 Inheritedoffset : FlxPoint
If you changed the size of your sprite object after loading or making the graphic, you might need to offset the graphic away from the bound box to center it the way you want.
FlxSprite
  on : Boolean
Use this to toggle checkbox-style behavior.
FlxButton
  onDown : Function
This function is called when the button is pressed down.
FlxButton
  onOut : Function
This function is called when the mouse leaves the button area.
FlxButton
  onOver : Function
This function is called when the mouse goes over the button.
FlxButton
  onUp : Function
This function is called when the button is released.
FlxButton
 Inheritedorigin : FlxPoint
WARNING: The origin of the sprite will default to its center.
FlxSprite
 Inheritedpath : FlxPath
A reference to a path object.
FlxObject
 InheritedpathAngle : Number
The angle in degrees between this object and the next node, where 0 is directly upward, and 90 is to the right.
FlxObject
 InheritedpathSpeed : Number
The speed at which the object is moving on the path.
FlxObject
 Inheritedpixels : BitmapData
Set pixels to any BitmapData object.
FlxSprite
  PRESSED : uint = 2
[static] Used with public variable status, means pressed (usually from mouse click).
FlxButton
 Inheritedscale : FlxPoint
Change the size of your sprite's graphic.
FlxSprite
 InheritedscrollFactor : FlxPoint
A point that can store numbers from 0 to 1 (for X and Y independently) that governs how much this object is affected by the camera subsystem.
FlxObject
 Inheritedsolid : Boolean
Whether the object collides or not.
FlxObject
  soundDown : FlxSound
Set this to play a sound when the button is pressed down.
FlxButton
  soundOut : FlxSound
Set this to play a sound when the mouse leaves the button.
FlxButton
  soundOver : FlxSound
Set this to play a sound when the mouse goes over the button.
FlxButton
  soundUp : FlxSound
Set this to play a sound when the button is released.
FlxButton
  status : uint
Shows the current state of the button.
FlxButton
 Inheritedtouching : uint
Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating surface contacts.
FlxObject
 Inheritedvelocity : FlxPoint
The basic speed of this object.
FlxObject
 Inheritedvisible : Boolean
Controls whether draw() is automatically called by FlxState/FlxGroup.
FlxBasic
 Inherited_VISIBLECOUNT : uint
[static]
FlxBasic
 InheritedwasTouching : uint
Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating surface contacts from the previous game loop step.
FlxObject
 Inheritedwidth : Number
The width of this object.
FlxObject
 Inheritedx : Number
X position of the upper left corner of this object in world space.
FlxObject
 Inheritedy : Number
Y position of the upper left corner of this object in world space.
FlxObject
Protected Properties
 PropertyDefined By
 Inherited_alpha : Number
Internal tracker for opacity, used with Flash getter/setter.
FlxSprite
 Inherited_animations : Array
Internal, stores all the animations that were added to this sprite.
FlxSprite
 Inherited_bakedRotation : Number
Internal tracker for how many frames of "baked" rotation there are (if any).
FlxSprite
 Inherited_callback : Function
Internal tracker for the animation callback.
FlxSprite
 Inherited_color : uint
Internal tracker for color tint, used with Flash getter/setter.
FlxSprite
 Inherited_colorTransform : ColorTransform
Internal, helps with animation, caching and drawing.
FlxSprite
 Inherited_curAnim : FlxAnim
Internal, keeps track of the current animation being played.
FlxSprite
 Inherited_curFrame : uint
Internal, keeps track of the current frame of animation.
FlxSprite
 Inherited_curIndex : uint
Internal, keeps track of the current index into the tile sheet based on animation or rotation.
FlxSprite
 Inherited_facing : uint
Internal tracker for what direction the sprite is currently facing, used with Flash getter/setter.
FlxSprite
 Inherited_flashPoint : Point
Internal, reused frequently during drawing and animating.
FlxSprite
 Inherited_flashPointZero : Point
Internal, reused frequently during drawing and animating.
FlxSprite
 Inherited_flashRect : Rectangle
Internal, reused frequently during drawing and animating.
FlxSprite
 Inherited_flashRect2 : Rectangle
Internal, reused frequently during drawing and animating.
FlxSprite
 Inherited_flicker : Boolean
Internal helper used for retro-style flickering.
FlxObject
 Inherited_flickerTimer : Number
Internal helper used for retro-style flickering.
FlxObject
 Inherited_flipped : uint
Internal, keeps track of whether the sprite was loaded with support for automatic reverse/mirroring.
FlxSprite
 Inherited_frameTimer : Number
Internal, used to time each frame of animation.
FlxSprite
 InheritedImgDefault : Class
FlxSprite
  ImgDefaultButton : Class
FlxButton
  _initialized : Boolean
Whether or not the button has initialized itself yet.
FlxButton
 Inherited_matrix : Matrix
Internal, helps with animation, caching and drawing.
FlxSprite
  _onToggle : Boolean
Used for checkbox-style behavior.
FlxButton
 Inherited_pathInc : int
Internal helper for node navigation, specifically yo-yo and backwards movement.
FlxObject
 Inherited_pathMode : uint
Internal tracker for path behavior flags (like looping, horizontal only, etc).
FlxObject
 Inherited_pathNodeIndex : int
Internal helper, tracks which node of the path this object is moving toward.
FlxObject
 Inherited_pathRotate : Boolean
Internal flag for whether hte object's angle should be adjusted to the path angle during path follow behavior.
FlxObject
 Inherited_pixels : BitmapData
Internal, stores the entire source graphic (not the current displayed animation frame), used with Flash getter/setter.
FlxSprite
 Inherited_point : FlxPoint
This is just a pre-allocated x-y point container to be used however you like
FlxObject
  _pressed : Boolean
Tracks whether or not the button is currently pressed.
FlxButton
 Inherited_rect : FlxRect
This is just a pre-allocated rectangle container to be used however you like
FlxObject
  SndBeep : Class
FlxButton
Public Methods
 MethodDefined By
  
FlxButton(X:Number = 0, Y:Number = 0, Label:String = null, OnClick:Function = null)
Creates a new FlxButton object with a gray background and a callback function on the UI thread.
FlxButton
 Inherited
addAnimation(Name:String, Frames:Array, FrameRate:Number = 0, Looped:Boolean = true):void
Adds a new animation to the sprite.
FlxSprite
 Inherited
addAnimationCallback(AnimationCallback:Function):void
Pass in a function to be called whenever this sprite's animation changes.
FlxSprite
 Inherited
centerOffsets(AdjustPosition:Boolean = false):void
Helper function that adjusts the offset automatically to center the bounding box within the graphic.
FlxSprite
  
destroy():void
[override] Called by the game state when state is changed (if this object belongs to the state)
FlxButton
  
draw():void
[override] Just draws the button graphic and text label to the screen.
FlxButton
 Inherited
drawDebug(Camera:FlxCamera = null):void
[override] Override this function to draw custom "debug mode" graphics to the specified camera while the debugger's visual mode is toggled on.
FlxObject
 Inherited
drawFrame(Force:Boolean = false):void
Request (or force) that the sprite update the frame before rendering.
FlxSprite
 Inherited
drawLine(StartX:Number, StartY:Number, EndX:Number, EndY:Number, Color:uint, Thickness:uint = 1):void
This function draws a line on this sprite from position X1,Y1 to position X2,Y2 with the specified color.
FlxSprite
 Inherited
fill(Color:uint):void
Fills this sprite's graphic with a specific color.
FlxSprite
 Inherited
flicker(Duration:Number = 1):void
Tells this object to flicker, retro-style.
FlxObject
 Inherited
followPath(Path:FlxPath, Speed:Number = 100, Mode:uint, AutoRotate:Boolean = false):void
Call this function to give this object a path to follow.
FlxObject
 Inherited
Retrieve the midpoint of this object in world coordinates.
FlxObject
 Inherited
getScreenXY(Point:FlxPoint = null, Camera:FlxCamera = null):FlxPoint
Call this function to figure out the on-screen position of the object.
FlxObject
 Inherited
hurt(Damage:Number):void
Reduces the "health" variable of this sprite by the amount specified in Damage.
FlxObject
 Inherited
isTouching(Direction:uint):Boolean
Handy function for checking if this object is touching a particular surface.
FlxObject
 Inherited
justTouched(Direction:uint):Boolean
Handy function for checking if this object is just landed on a particular surface.
FlxObject
 Inherited
kill():void
Handy function for "killing" game objects.
FlxBasic
 Inherited
loadGraphic(Graphic:Class, Animated:Boolean = false, Reverse:Boolean = false, Width:uint = 0, Height:uint = 0, Unique:Boolean = false):FlxSprite
Load an image from an embedded graphic file.
FlxSprite
 Inherited
loadRotatedGraphic(Graphic:Class, Rotations:uint = 16, Frame:int = -1, AntiAliasing:Boolean = false, AutoBuffer:Boolean = false):FlxSprite
Create a pre-rotated sprite sheet from a simple sprite.
FlxSprite
 Inherited
makeGraphic(Width:uint, Height:uint, Color:uint = 0xffffffff, Unique:Boolean = false, Key:String = null):FlxSprite
This function creates a flat colored square image dynamically.
FlxSprite
 Inherited
onScreen(Camera:FlxCamera = null):Boolean
[override] Check and see if this object is currently on screen.
FlxSprite
 Inherited
overlaps(ObjectOrGroup:FlxBasic, InScreenSpace:Boolean = false, Camera:FlxCamera = null):Boolean
Checks to see if some FlxObject overlaps this FlxObject or FlxGroup.
FlxObject
 Inherited
overlapsAt(X:Number, Y:Number, ObjectOrGroup:FlxBasic, InScreenSpace:Boolean = false, Camera:FlxCamera = null):Boolean
Checks to see if this FlxObject were located at the given position, would it overlap the FlxObject or FlxGroup? This is distinct from overlapsPoint(), which just checks that point, rather than taking the object's size into account.
FlxObject
 Inherited
overlapsPoint(Point:FlxPoint, InScreenSpace:Boolean = false, Camera:FlxCamera = null):Boolean
Checks to see if a point in 2D world space overlaps this FlxObject object.
FlxObject
 Inherited
pixelsOverlapPoint(Point:FlxPoint, Mask:uint = 0xFF, Camera:FlxCamera = null):Boolean
Checks to see if a point in 2D world space overlaps this FlxSprite object's current displayed pixels.
FlxSprite
 Inherited
play(AnimName:String, Force:Boolean = false):void
Plays an existing animation (e.g.
FlxSprite
 Inherited
postUpdate():void
[override] Automatically called after update() by the game loop, this function just calls updateAnimation().
FlxSprite
  
preUpdate():void
[override] Since button uses its own mouse handler for thread reasons, we run a little pre-check here to make sure that we only add the mouse handler when it is actually safe to do so.
FlxButton
 Inherited
Tell the sprite to change to a random frame of animation Useful for instantiating particles or other weird things.
FlxSprite
 Inherited
replaceColor(Color:uint, NewColor:uint, FetchPositions:Boolean = false):Array
FlxSprite
 Inherited
reset(X:Number, Y:Number):void
Handy function for reviving game objects.
FlxObject
 Inherited
revive():void
Handy function for bringing game objects "back to life".
FlxBasic
 Inherited
separate(Object1:FlxObject, Object2:FlxObject):Boolean
[static] The main collision resolution function in flixel.
FlxObject
 Inherited
separateX(Object1:FlxObject, Object2:FlxObject):Boolean
[static] The X-axis component of the object separation process.
FlxObject
 Inherited
separateY(Object1:FlxObject, Object2:FlxObject):Boolean
[static] The Y-axis component of the object separation process.
FlxObject
 Inherited
Helper function that just sets origin to (0,0)
FlxSprite
  
setSounds(SoundOver:Class = null, SoundOverVolume:Number = 1.0, SoundOut:Class = null, SoundOutVolume:Number = 1.0, SoundDown:Class = null, SoundDownVolume:Number = 1.0, SoundUp:Class = null, SoundUpVolume:Number = 1.0):void
Set sounds to play during mouse-button interactions.
FlxButton
 Inherited
stamp(Brush:FlxSprite, X:int = 0, Y:int = 0):void
This function draws or stamps one FlxSprite onto another.
FlxSprite
 Inherited
stopFollowingPath(DestroyPath:Boolean = false):void
Tells this object to stop following the path its on.
FlxObject
 Inherited
toString():String
Convert object to readable string name.
FlxBasic
  
update():void
[override] Called by the game loop automatically, handles mouseover and click detection.
FlxButton
Protected Methods
 MethodDefined By
 Inherited
advancePath(Snap:Boolean = true):FlxPoint
Internal function that decides what node in the path to aim for next based on the behavior flags.
FlxObject
 Inherited
calcFrame():void
Internal function to update the current animation frame.
FlxSprite
  
onMouseUp(event:MouseEvent):void
Internal function for handling the actual callback call (for UI thread dependent calls like FlxU.openURL()).
FlxButton
  
[override] Updates the size of the text field to match the button.
FlxButton
 Inherited
Internal function for updating the sprite's animation.
FlxSprite
  
Basic button update logic
FlxButton
 Inherited
Internal function for updating the position and speed of this object.
FlxObject
 Inherited
Internal function for moving the object along the path.
FlxObject
Public Constants
 ConstantDefined By
 InheritedANY : uint
[static] Special-case constant meaning any direction, used mainly by allowCollisions and touching.
FlxObject
 InheritedCEILING : uint = 0x0100
[static] Special-case constant meaning up, used mainly by allowCollisions and touching.
FlxObject
 InheritedDOWN : uint = 0x1000
[static] Generic value for "down" Used by facing, allowCollisions, and touching.
FlxObject
 InheritedFLOOR : uint = 0x1000
[static] Special-case constant meaning down, used mainly by allowCollisions and touching.
FlxObject
 InheritedLEFT : uint = 0x0001
[static] Generic value for "left" Used by facing, allowCollisions, and touching.
FlxObject
 InheritedNONE : uint = 0
[static] Special-case constant meaning no collisions, used mainly by allowCollisions and touching.
FlxObject
 InheritedOVERLAP_BIAS : Number = 4
[static] Handy constant used during collision resolution (see separateX() and separateY()).
FlxObject
 InheritedPATH_BACKWARD : uint = 0x000001
[static] Path behavior controls: move from the end of the path to the start then stop.
FlxObject
 InheritedPATH_FORWARD : uint = 0x000000
[static] Path behavior controls: move from the start of the path to the end then stop.
FlxObject
 InheritedPATH_HORIZONTAL_ONLY : uint = 0x010000
[static] Path behavior controls: ignores any vertical component to the path data, only follows side to side.
FlxObject
 InheritedPATH_LOOP_BACKWARD : uint = 0x000100
[static] Path behavior controls: move from the end of the path to the start then directly back to the end, and start over.
FlxObject
 InheritedPATH_LOOP_FORWARD : uint = 0x000010
[static] Path behavior controls: move from the start of the path to the end then directly back to the start, and start over.
FlxObject
 InheritedPATH_VERTICAL_ONLY : uint = 0x100000
[static] Path behavior controls: ignores any horizontal component to the path data, only follows up and down.
FlxObject
 InheritedPATH_YOYO : uint = 0x001000
[static] Path behavior controls: move from the start of the path to the end then turn around and go back to the start, over and over.
FlxObject
 InheritedRIGHT : uint = 0x0010
[static] Generic value for "right" Used by facing, allowCollisions, and touching.
FlxObject
 InheritedUP : uint = 0x0100
[static] Generic value for "up" Used by facing, allowCollisions, and touching.
FlxObject
 InheritedWALL : uint
[static] Special-case constant meaning only the left and right sides, used mainly by allowCollisions and touching.
FlxObject
Protected Constants
 ConstantDefined By
 Inherited_pZero : FlxPoint
[static] Should always represent (0,0) - useful for different things, for avoiding unnecessary new calls.
FlxObject
Property Detail
_initializedproperty
protected var _initialized:Boolean

Whether or not the button has initialized itself yet.

_onToggleproperty 
protected var _onToggle:Boolean

Used for checkbox-style behavior.

_pressedproperty 
protected var _pressed:Boolean

Tracks whether or not the button is currently pressed.

HIGHLIGHTproperty 
public static var HIGHLIGHT:uint = 1

Used with public variable status, means highlighted (usually from mouse over).

ImgDefaultButtonproperty 
protected var ImgDefaultButton:Class

labelproperty 
public var label:FlxText

The text that appears on the button.

labelOffsetproperty 
public var labelOffset:FlxPoint

Controls the offset (from top left) of the text from the button.

NORMALproperty 
public static var NORMAL:uint = 0

Used with public variable status, means not highlighted or pressed.

onproperty 
on:Boolean

Use this to toggle checkbox-style behavior.


Implementation
    public function get on():Boolean
    public function set on(value:Boolean):void
onDownproperty 
public var onDown:Function

This function is called when the button is pressed down.

onOutproperty 
public var onOut:Function

This function is called when the mouse leaves the button area.

onOverproperty 
public var onOver:Function

This function is called when the mouse goes over the button.

onUpproperty 
public var onUp:Function

This function is called when the button is released. We recommend assigning your main button behavior to this function via the FlxButton constructor.

PRESSEDproperty 
public static var PRESSED:uint = 2

Used with public variable status, means pressed (usually from mouse click).

SndBeepproperty 
protected var SndBeep:Class

soundDownproperty 
public var soundDown:FlxSound

Set this to play a sound when the button is pressed down. We recommend using the helper function setSounds()!

soundOutproperty 
public var soundOut:FlxSound

Set this to play a sound when the mouse leaves the button. We recommend using the helper function setSounds()!

soundOverproperty 
public var soundOver:FlxSound

Set this to play a sound when the mouse goes over the button. We recommend using the helper function setSounds()!

soundUpproperty 
public var soundUp:FlxSound

Set this to play a sound when the button is released. We recommend using the helper function setSounds()!

statusproperty 
public var status:uint

Shows the current state of the button.

Constructor Detail
FlxButton()Constructor
public function FlxButton(X:Number = 0, Y:Number = 0, Label:String = null, OnClick:Function = null)

Creates a new FlxButton object with a gray background and a callback function on the UI thread.

Parameters
X:Number (default = 0) — The X position of the button.
 
Y:Number (default = 0) — The Y position of the button.
 
Label:String (default = null) — The text that you want to appear on the button.
 
OnClick:Function (default = null) — The function to call whenever the button is clicked.
Method Detail
destroy()method
override public function destroy():void

Called by the game state when state is changed (if this object belongs to the state)

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

Just draws the button graphic and text label to the screen.

onMouseUp()method 
protected function onMouseUp(event:MouseEvent):void

Internal function for handling the actual callback call (for UI thread dependent calls like FlxU.openURL()).

Parameters

event:MouseEvent

preUpdate()method 
override public function preUpdate():void

Since button uses its own mouse handler for thread reasons, we run a little pre-check here to make sure that we only add the mouse handler when it is actually safe to do so.

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

Updates the size of the text field to match the button.

setSounds()method 
public function setSounds(SoundOver:Class = null, SoundOverVolume:Number = 1.0, SoundOut:Class = null, SoundOutVolume:Number = 1.0, SoundDown:Class = null, SoundDownVolume:Number = 1.0, SoundUp:Class = null, SoundUpVolume:Number = 1.0):void

Set sounds to play during mouse-button interactions. These operations can be done manually as well, and the public sound variables can be used after this for more fine-tuning, such as positional audio, etc.

Parameters

SoundOver:Class (default = null) — What embedded sound effect to play when the mouse goes over the button. Default is null, or no sound.
 
SoundOverVolume:Number (default = 1.0) — How load the that sound should be.
 
SoundOut:Class (default = null) — What embedded sound effect to play when the mouse leaves the button area. Default is null, or no sound.
 
SoundOutVolume:Number (default = 1.0) — How load the that sound should be.
 
SoundDown:Class (default = null) — What embedded sound effect to play when the mouse presses the button down. Default is null, or no sound.
 
SoundDownVolume:Number (default = 1.0) — How load the that sound should be.
 
SoundUp:Class (default = null) — What embedded sound effect to play when the mouse releases the button. Default is null, or no sound.
 
SoundUpVolume:Number (default = 1.0) — How load the that sound should be.

update()method 
override public function update():void

Called by the game loop automatically, handles mouseover and click detection.

updateButton()method 
protected function updateButton():void

Basic button update logic