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! E.g.
FlxSprite
 Inheritedcameras : Array
FlxSprite
 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
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
 Inheritedframes : uint
The total number of frames in this image (assumes each row is full).
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
FlxObject
  HIGHLIGHT : uint = 1
[static]
FlxButton
 InheritedID : int
IDs seem like they could be pretty useful, huh?
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
FlxObject
 Inheritedmass : Number
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]
FlxButton
 Inheritedoffset : FlxPoint
If you changed the size of your sprite object to shrink the bounding box, you might need to offset the new bounding box from the top-left corner of the sprite.
FlxSprite
  on : Boolean
Use this to toggle checkbox-style behavior.
FlxButton
 Inheritedorigin : FlxPoint
WARNING: The origin of the sprite will default to its center.
FlxSprite
  pauseProof : Boolean
Set this to true if you want this button to function even while the game is paused.
FlxButton
 Inheritedpixels : BitmapData
Set pixels to any BitmapData object.
FlxSprite
  PRESSED : uint = 2
[static]
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
FlxObject
 Inheritedtouching : uint
Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating surface contacts and collision qualities.
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
FlxObject
 Inheritedwidth : Number
FlxObject
 Inheritedx : Number
FlxObject
 Inheritedy : Number
FlxObject
Protected Properties
 PropertyDefined By
 Inherited_alpha : Number
FlxSprite
 Inherited_animations : Array
FlxSprite
 Inherited_bakedRotation : Number
FlxSprite
 Inherited_caf : uint
FlxSprite
 Inherited_callback : Function
FlxSprite
 Inherited_color : uint
FlxSprite
 Inherited_ct : ColorTransform
FlxSprite
 Inherited_curAnim : FlxAnim
FlxSprite
 Inherited_curFrame : uint
FlxSprite
 Inherited_facing : uint
FlxSprite
 Inherited_flashPoint : Point
FlxSprite
 Inherited_flashPointZero : Point
FlxSprite
 Inherited_flashRect : Rectangle
FlxSprite
 Inherited_flashRect2 : Rectangle
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
FlxSprite
 Inherited_framePixels : BitmapData
FlxSprite
 Inherited_frameTimer : Number
FlxSprite
 Inherited_gfx : Graphics
[static]
FlxSprite
 Inherited_gfxSprite : Sprite
[static]
FlxSprite
 InheritedImgDefault : Class
FlxSprite
  ImgDefaultButton : Class
FlxButton
  _initialized : Boolean
Whether or not the button has initialized itself yet.
FlxButton
 Inherited_mtx : Matrix
FlxSprite
  _onClick : Function
This function is called when the button is clicked.
FlxButton
  _onToggle : Boolean
Used for checkbox-style behavior.
FlxButton
 Inherited_pixels : BitmapData
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
  _status : uint
Shows the current state of the button.
FlxButton
Public Methods
 MethodDefined By
  
FlxButton(X:int, Y:int, Callback:Function, Label:String = 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
corner():void
FlxSprite
  
destroy():void
[override] Called by the game state when state is changed (if this object belongs to the state)
FlxButton
  
draw():void
[override]
FlxButton
 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
FlxObject
 Inherited
getScreenXY(Point:FlxPoint = null, Camera:FlxCamera = null):FlxPoint
[override] Call this function to figure out the on-screen position of the object.
FlxSprite
 Inherited
hurt(Damage:Number):void
Reduces the "health" variable of this sprite by the amount specified in Damage.
FlxSprite
 Inherited
isTouching(Direction:uint):Boolean
FlxObject
 Inherited
justTouched(Direction:uint):Boolean
FlxObject
 Inherited
kill():void
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
onEmit():void
Triggered whenever this sprite is launched by a FlxEmitter.
FlxSprite
 Inherited
onScreen(Camera:FlxCamera = null):Boolean
[override] Check and see if this object is currently on screen.
FlxSprite
 Inherited
overlaps(Object:FlxObject):Boolean
Checks to see if some FlxObject overlaps this FlxObject object in world space.
FlxObject
 Inherited
overlapsPoint(X:Number, Y:Number, Camera:FlxCamera = null, PerPixel:Boolean = false):Boolean
[override] Checks to see if a point in 2D world space overlaps this FlxCore object.
FlxSprite
 Inherited
play(AnimName:String, Force:Boolean = false):void
Plays an existing animation (e.g.
FlxSprite
 Inherited
postUpdate():void
[override]
FlxSprite
  
preUpdate():void
[override]
FlxButton
 Inherited
Tell the sprite to change to a random frame of animation Useful for instantiating particles or other weird things.
FlxSprite
 Inherited
reset(X:Number, Y:Number):void
Handy function for reviving game objects.
FlxObject
 Inherited
revive():void
FlxBasic
 Inherited
separate(Object1:FlxObject, Object2:FlxObject):Boolean
[static]
FlxObject
 Inherited
separateX(Object1:FlxObject, Object2:FlxObject):Boolean
[static]
FlxObject
 Inherited
separateY(Object1:FlxObject, Object2:FlxObject):Boolean
[static]
FlxObject
 Inherited
stamp(Brush:FlxSprite, X:int = 0, Y:int = 0):void
This function draws or stamps one FlxSprite onto another.
FlxSprite
 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
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] Attempting to update 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
Public Constants
 ConstantDefined By
 InheritedANY : uint
[static]
FlxObject
 InheritedCEILING : uint = 0x0100
[static]
FlxObject
 InheritedDOWN : uint = 0x1000
[static]
FlxObject
 InheritedFLOOR : uint = 0x1000
[static]
FlxObject
 InheritedLEFT : uint = 0x0001
[static]
FlxObject
 InheritedNONE : uint = 0
[static]
FlxObject
 InheritedOVERLAP_BIAS : Number = 4
[static]
FlxObject
 InheritedRIGHT : uint = 0x0010
[static]
FlxObject
 InheritedUP : uint = 0x0100
[static]
FlxObject
 InheritedWALL : uint
[static]
FlxObject
Protected Constants
 ConstantDefined By
 Inherited_pZero : FlxPoint
[static] A handy "empty point" object
FlxObject
Property Detail
_initializedproperty
protected var _initialized:Boolean

Whether or not the button has initialized itself yet.

_onClickproperty 
protected var _onClick:Function

This function is called when the button is clicked.

_onToggleproperty 
protected var _onToggle:Boolean

Used for checkbox-style behavior.

_pressedproperty 
protected var _pressed:Boolean

Tracks whether or not the button is currently pressed.

_statusproperty 
protected var _status:uint

Shows the current state of the button.

HIGHLIGHTproperty 
public static var HIGHLIGHT:uint = 1

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

onproperty 
on:Boolean

Use this to toggle checkbox-style behavior.


Implementation
    public function get on():Boolean
    public function set on(value:Boolean):void
pauseProofproperty 
public var pauseProof:Boolean

Set this to true if you want this button to function even while the game is paused.

PRESSEDproperty 
public static var PRESSED:uint = 2

Constructor Detail
FlxButton()Constructor
public function FlxButton(X:int, Y:int, Callback:Function, Label:String = null)

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

Parameters
X:int — The X position of the button.
 
Y:int — The Y position of the button.
 
Callback:Function — The function to call whenever the button is clicked.
 
Label:String (default = null) — The text that you want to appear on the button.
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

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

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

Attempting to update the size of the text field to match the button.

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