ShapeButton |
A button widget with a slightly raised look and an optional graphics shape placed above an optional label text.
BubbleButton, LabelButton, ToggleButton.
| ShapeButton | A button widget with a slightly raised look and an optional graphics shape placed above an optional label text. |
| Private display constants | |
| LABEL_MARGIN | Small margin to keep the text label from the button border. |
| DEFAULT_WIDTH | Default button width |
| DEFAULT_HEIGHT | Default button height |
| Private display members | |
| cornerSize | Rounded corner size. |
| Private state members | |
| downState | Sprite displayed when the button is pressed. |
| upState | Sprite displayed when the button is not pressed. |
| lastState | Last state the button has been in. |
| Private data members | |
| callback | Callback function called when the button is clicked or auto-repeats. |
| timer | Timer used when the button auto-repeats. |
| repeat | Repeat interval in milliseconds. |
| Constructor | |
| ShapeButton | Creates a button with a graphics shape and/or a label text. |
| Public properties | |
| name | Sets the display object instance name for all the parts of the button. |
| Mouse event methods | |
| mouseDownHandler | Called when the mouse button is pressed. |
| mouseUpHandler | Called when the mouse button is released. |
| mouseOutHandler | Called when the mouse is moved away from the button. |
| Auto-repeat methods | |
| start | Start auto-repeating clicks on the button. |
| stop | Stops and removes the auto-repeat timer. |
| timerHandler | Handles the timer callback for auto-repeat of the button. |
| Private display methods | |
| resizeText | Centers the text on the button. |
| getBitmapFilter | Gets a bevel bitmap filter to give the button a raised look. |
| 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 ShapeButton( owner: String, upShapeFunction: Function, downShapeFunction: Function, labelText: String = null, color: uint = Color.Grey, clickHandler: Function = null, buttonWidth: Number = DEFAULT_WIDTH, buttonHeight: Number = DEFAULT_HEIGHT, autoRepeat: int = 100 )
Creates a button with a graphics shape and/or a label text. Thebutton has up/down states and auto-repeat capability. The up/downShapeFunction signatures are: function createShape():Shape. The clickHandler callback signature is: function clickHandler():void.
| owner | name of registered owner; see WidgetSprite.register |
| upShapeFunction | function returning a graphics shape for the button up state |
| downShapeFunction | function returning a graphics shape for the button down state |
| labelText | text string to be placed on the button |
| color | base theme color for the button |
| clickHandler | a callback function that is called when the button has been clicked |
| buttonWidth | width of the button (default 70 pixels) |
| buttonHeight | height of the button (default 20 pixels) |
| autoRepeat | milliseconds between auto-repeat events, set to -1 to disable (default 100) |
| clickHandler | function onShapeButtonClick():void |
private function mouseDownHandler( event: MouseEvent ):void
Called when the mouse button is pressed. Changes the button to the down state and starts the auto-repeat timer if its interval is set to zero or larger. An auto-repeat value of -1 therefore disables auto-repeat.
| event | a mouse event |
private function resizeText( textLabel: Label, buttonWidth: Number, buttonHeight: Number ):void
Centers the text on the button. If the text is wider than the button then it is scaled down to fit.
| textLabel | text label placed on the button |
| buttonWidth | width of the button |
| buttonHeight | height of the button |
Small margin to keep the text label from the button border.
private const LABEL_MARGIN: uint
Default button width
private const DEFAULT_WIDTH: uint
Default button height
private const DEFAULT_HEIGHT: uint
Rounded corner size.
private var cornerSize: uint
Sprite displayed when the button is pressed.
private var downState: Sprite
Sprite displayed when the button is not pressed.
private var upState: Sprite
Last state the button has been in.
private var lastState: DisplayObject
Callback function called when the button is clicked or auto-repeats.
private var callback: Function
Timer used when the button auto-repeats.
private var timer: Timer
Repeat interval in milliseconds.
private var repeat: int
Creates a button with a graphics shape and/or a label text.
public function ShapeButton( owner: String, upShapeFunction: Function, downShapeFunction: Function, labelText: String = null, color: uint = Color.Grey, clickHandler: Function = null, buttonWidth: Number = DEFAULT_WIDTH, buttonHeight: Number = DEFAULT_HEIGHT, autoRepeat: int = 100 )
Sets the display object instance name for all the parts of the button.
public override function set name( labelName: String ):void
Called when the mouse button is pressed.
private function mouseDownHandler( event: MouseEvent ):void
Called when the mouse button is released.
private function mouseUpHandler( event: MouseEvent ):void
Called when the mouse is moved away from the button.
private function mouseOutHandler( event: MouseEvent ):void
Start auto-repeating clicks on the button.
private function start( interval: uint ):void
Stops and removes the auto-repeat timer.
private function stop():void
Handles the timer callback for auto-repeat of the button.
private function timerHandler( event: TimerEvent ):void
Centers the text on the button.
private function resizeText( textLabel: Label, buttonWidth: Number, buttonHeight: Number ):void
Gets a bevel bitmap filter to give the button a raised look.
private function getBitmapFilter( color: uint ):BitmapFilter
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