Access keys

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");
    }
}

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.

doPress

function doPress (
)
Implementation of DelayButton press method.

doRelease

function doRelease (
)
Implementation of DelayButton release method.

doRollOut

function doRollOut (
)
Implementation of DelayButton roll out method.

doRollOver

function doRollOver (
)
Implementation of DelayButton roll over method.

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

toString

function toString (
) : String

Event handlers

onLoad

function onLoad (
)