BubbleButton |
An action button drawn as a bubble with an optional symbol on top. Use of this class should be deprecated, use ShapeButton instead.
Events are intercepted in the capture phase meaning that target testing must be performed in the class where the buttons are used.
LabelButton, ShapeButton, ToggleButton.
// Add/remove/handle a close button centered on a Sprite import flash.events.MouseEvent; var closeButton:BubbleButton = null; // Add button closeButton = new BubbleButton(mouseCloseHandler, bgColor, BubbleButton.SYMBOL_X); closeButton.name = "CloseButton"; closeButton.x = width/2 - closeButton.width/2; closeButton.y = height/2 - closeButton.height/2; addChild(closeButton); // Remove button if (closeButton != null) { closeButton.dispose(); closeButton = null; } // Handle button press private function mouseCloseHandler(event:MouseEvent):void { // Perform action }
Using flash.display.SimpleButton consumed an excessive amount of CPU when a dozen of instances (FP9r16) were used so all use of SimpleButton has been eliminated.
BubbleButton | An action button drawn as a bubble with an optional symbol on top. |
Public constants | |
DEFAULT_SIZE | Default button diameter in pixels |
SYMBOL_NONE | No symbol is drawn on the button |
SYMBOL_X | An X symbol (close) is drawn on the button |
SYMBOL_DOT | A dot is drawn on the button |
SYMBOL_CIRCLE | A circle is drawn on the button |
private data members | |
downState | Visual state of the button when it is pressed down |
overState | Visual state of the button when the mouse hovers over it |
upState | Visual state of the button when it is unselected |
lastState | Last active visual state of the button |
callback | Function called when the button is clicked |
Constructor | |
BubbleButton | Creates a button drawn as a bubble. |
Event Handlers | |
mouseDownHandler | Change state when the button is pressed |
mouseUpHandler | Change state when the button is released |
mouseOutHandler | Change state when the mouse is moved away from the button |
mouseOverHandler | Change state when the mouse is over the button |
mouseClickHandler | Button click handler calls back to user supplied handler if present |
WidgetInterface | |
active | Sets the state of the widget to active or inactive. |
activate | Activates the widget, adds its event listeners |
disactivate | Disactivates the widget, removes its event listeners |
dispose | Dispose of all resources used or referenced in the instance. |
destructor | Removes used resources, references and graphics |
public function BubbleButton( owner: String, clickHandler: Function = null, color: uint = Color.White, symbol: uint = SYMBOL_NONE, size: uint = DEFAULT_SIZE )
Creates a button drawn as a bubble. Drawn with simulated highlight and shadow.
owner | name of registered owner; see WidgetSprite.register |
clickHandler | MouseEvent handler function called when the button is clicked |
color | is the base color of the button - assumed to be in the Color class palette |
symbol | graphic imprinted on the button (default is SYMBOL_NONE) |
size | button diameter in pixels excluding any shadow |
clickHandler | function onBubbleButtonClick(event:MouseEvent):void |
Default button diameter in pixels
public static const DEFAULT_SIZE: uint
No symbol is drawn on the button
public static const SYMBOL_NONE: uint
An X symbol (close) is drawn on the button
public static const SYMBOL_X: uint
A dot is drawn on the button
public static const SYMBOL_DOT: uint
A circle is drawn on the button
public static const SYMBOL_CIRCLE: uint
Visual state of the button when it is pressed down
private var downState: BubbleButtonState
Visual state of the button when the mouse hovers over it
private var overState: BubbleButtonState
Visual state of the button when it is unselected
private var upState: BubbleButtonState
Last active visual state of the button
private var lastState: DisplayObject
Function called when the button is clicked
private var callback: Function
Creates a button drawn as a bubble.
public function BubbleButton( owner: String, clickHandler: Function = null, color: uint = Color.White, symbol: uint = SYMBOL_NONE, size: uint = DEFAULT_SIZE )
Change state when the button is pressed
private function mouseDownHandler( event: MouseEvent ):void
Change state when the button is released
private function mouseUpHandler( event: MouseEvent ):void
Change state when the mouse is moved away from the button
private function mouseOutHandler( event: MouseEvent ):void
Change state when the mouse is over the button
private function mouseOverHandler( event: MouseEvent ):void
Button click handler calls back to user supplied handler if present
private function mouseClickHandler( event: MouseEvent ):void
Sets the state of the widget to active or inactive.
public function set active( state: Boolean ):void
Activates the widget, adds its event listeners
private function activate():void
Disactivates the widget, removes its event listeners
private function disactivate():void
Dispose of all resources used or referenced in the instance.
public function dispose():void
Removes used resources, references and graphics
private function destructor():void
Register the owner of a widget.
public function register( owner: String ):void