SelectableButton
| Kind of class: | class |
|---|---|
| Inherits from: | DelayButton < EventButton < EventMovieClip < MovieClip |
| Author: | Arthur Clemens |
| Classpath: | org.asapframework.ui.buttons.SelectableButton |
| File last modified: | Sunday, 08 October 2006, 10:14:51 |
Convenience class to create buttons with a "selected" state, for instance to be used in menus.
SelectableButton takes care of state management like event handling and the specific bahavior of the selected button. Subclasses only need to take care of drawing each button state: up, over and selected.
SelectableButton offers cascading functionality from superclasses:
- Control timing with indelay, outdelay and afterdelay from DelayButton
- Use setSendEventOnRoll and setSendEventOnPress to control dispatching of events (EventButton)
Usage:
An example for a SelectableButton subclass, MenuButton:
import org.asapframework.ui.buttons.SelectableButton; class MenuButton extends org.asapframework.ui.buttons.SelectableButton { private function drawUpState () : Void { gotoAndStop("up"); } private function drawOverState () : Void { gotoAndStop("over"); } private function drawSelectedState () : Void { gotoAndStop("selected"); } }An example for a "next" button subclass that shows an disabled state:
class NextButton extends SelectableButton { public function NextButton () { super(); setSendEventOnPress(true); // let the button send events on onPress } private function drawUpState () : Void { gotoAndStop("up"); } private function drawOverState () : Void { gotoAndStop("over"); } private function drawDisabledState () : Void { gotoAndStop("disabled"); } private function drawEnabledState () : Void { gotoAndStop("up"); } }
Summary
Constructor
Instance properties
Instance properties inherited from DelayButton
Instance properties inherited from EventButton
Instance properties inherited from EventMovieClip
Instance methods
Instance methods inherited from DelayButton
Instance methods inherited from EventButton
Event handlers
Event handlers inherited from DelayButton
Event handlers inherited from EventButton
Constructor
SelectableButton
function SelectableButton (
)
Creates a new SelectableButton. Calls init to initialize variables.
Instance methods
deselect
function deselect (
) : Void
Sets the button state to deselected.
getId
function getId (
) : String
Gets the state id.
Returns:
The id.
select
function select (
) : Void
Sets the button state to selected.
setEnabled
function setEnabled (
inState:Boolean) : Void
Sets the button to enabled of disabled. Use this method; do not call
.enabled on the button directly.Parameters:
inState:
true sets state to enabled; false to disabled
setId
function setId (
inId:String) : Void
Sets the state id.
Parameters:
inId:
the id