NumberInput

A floating point number input field with an optional label and optional auto-repeating stepper buttons.  The data entry area is indicated with a stippled line.

See also

IntegerInput, StringInput.

Summary
NumberInputA floating point number input field with an optional label and optional auto-repeating stepper buttons.
public static constants
DEFAULT_LABEL_WIDTHDefault width of the optional label in pixels
DEFAULT_INPUT_WIDTHDefault width of the numeric input field in pixels
defaultColorDefault color of the text in the field and the label
defaultFontSizeA medium default size for the font.
defaultStepperSizeStepper size, each stepper is square
Private data members
inputInternal text field used to display and edit the data.
plusButtonSmall stepper/spin button for incrementing the value in the field.
minusButtonSmall stepper/spin button for decrementing the value in the field.
callbackCallback function called when the field has been changed.
stepColorBase theme color of the stepper buttons
Public properties
precisionNumber of fractional decimal digits shown
stepStep size used when incrementing/decrementing
minimumThe smallest value that the field will be decremented to.
maximumThe largest value that the field will be incremented to.
Constructor
NumberInputCreates a floating point number input field with an optional label and optional auto-repeating stepper buttons.
Public properties
valueGet the numeric value from the field.
valueChange the field to a new numeric value.
Event handlers
incrementIncrements the field value when the user clicks or auto-repeats the up stepper button by keeping it pressed.
decrementDecrements the field value when the user clicks or auto-repeats the down stepper button by keeping it pressed.
inputChangeHandlerTriggers a set change callback when the text in the input field has been changed.
WidgetInterface
activeSets the state of the widget to active or inactive.
activateActivates the widget, adds its event listeners
disactivateDisactivates the widget, removes its event listeners
disposeDispose of all resources used or referenced in the instance.
destructorRemoves used resources, references and graphics

public static constants

DEFAULT_LABEL_WIDTH

public static const DEFAULT_LABEL_WIDTH: uint

Default width of the optional label in pixels

DEFAULT_INPUT_WIDTH

public static const DEFAULT_INPUT_WIDTH: uint

Default width of the numeric input field in pixels

defaultColor

public static const defaultColor: int

Default color of the text in the field and the label

defaultFontSize

public static const defaultFontSize: int

A medium default size for the font.

defaultStepperSize

public static const defaultStepperSize: int

Stepper size, each stepper is square

Private data members

input

private var input: TextField

Internal text field used to display and edit the data.

plusButton

private var plusButton: ShapeButton

Small stepper/spin button for incrementing the value in the field.

minusButton

private var minusButton: ShapeButton

Small stepper/spin button for decrementing the value in the field.

callback

private var callback: Function

Callback function called when the field has been changed.

stepColor

private var stepColor: uint

Base theme color of the stepper buttons

Public properties

precision

public var precision: int

Number of fractional decimal digits shown

step

public var step: Number

Step size used when incrementing/decrementing

minimum

public var minimum: Number

The smallest value that the field will be decremented to.  Note that the user can type in smaller values since data validation is not performed on text entry.

maximum

public var maximum: Number

The largest value that the field will be incremented to.  Note that the user can type in larger values since data validation is not performed on text entry.

Constructor

NumberInput

public function NumberInput(owner: String,  
labelText: String = null,
inputValue: Number = 0.0,
changeHandler: Function = null,
useStepper: Boolean = true,
stepperColor: uint = Color.Grey,
labelWidth: uint = DEFAULT_LABEL_WIDTH,
inputWidth: uint = DEFAULT_INPUT_WIDTH,
color: uint = defaultColor,
fontSize: uint = defaultFontSize)

Creates a floating point number input field with an optional label and optional auto-repeating stepper buttons.

Parameters

ownername of registered owner; see WidgetSprite.register
labelTexttext to use as a label for the field (default null for no label)
inputValueinitial numeric value (default 0.0)
changeHandlerfunction called when the field value changes (default null)
useStepperdisplays an up/down stepper if true (default true)
stepperColorbase theme color for the number stepper (default Grey)
labelWidthwidth of the label (default 80 pixels)
inputWidthwidth of the field (default 70 pixels)
colorbase theme color for the field font and label (default MediumGrey)
fontSizesize of the font used (default 10)

Callbacks

changeHandlerfunction onNumberInputChange(value:Number):void

Public properties

value

public function get value():Number

Get the numeric value from the field.

Returns

Current field value as a number

value

public function set value(float: Number):void

Change the field to a new numeric value.  Uses the precision set for the field to limit the number of digits displayed after the decimal point.  Triggers a change callback if one is set.

Parameters

floatnew integer value

Event handlers

increment

private function increment():void

Increments the field value when the user clicks or auto-repeats the up stepper button by keeping it pressed.  The increment is calculated relative to the current value of the field.  At zero it is the step value set for the field.  The value is limited at the maximum value set for the field.

decrement

private function decrement():void

Decrements the field value when the user clicks or auto-repeats the down stepper button by keeping it pressed.  The decrement is calculated relative to the current value of the field.  At zero it is the step value set for the field.  The value is limited at the minimum value set for the field.

inputChangeHandler

private function inputChangeHandler(event: Event):void

Triggers a set change callback when the text in the input field has been changed.

Parameters

eventan Event.CHANGE event

WidgetInterface

active

public function set active(state: Boolean):void

Sets the state of the widget to active or inactive.

Parameters

stateTrue to activate, false otherwise.

activate

private function activate():void

Activates the widget, adds its event listeners

disactivate

private function disactivate():void

Disactivates the widget, removes its event listeners

dispose

public function dispose():void

Dispose of all resources used or referenced in the instance.

destructor

private function destructor():void

Removes used resources, references and graphics

Widgets are required to implement this interface.
Base class for widgets to enable/disable event listeners and keep a global tab order of all widgets (provided they are created and registered in tab order.
public static const DEFAULT_LABEL_WIDTH: uint
Default width of the optional label in pixels
public static const DEFAULT_INPUT_WIDTH: uint
Default width of the numeric input field in pixels
public static const defaultColor: int
Default color of the text in the field and the label
public static const defaultFontSize: int
A medium default size for the font.
public static const defaultStepperSize: int
Stepper size, each stepper is square
private var input: TextField
Internal text field used to display and edit the data.
private var plusButton: ShapeButton
Small stepper/spin button for incrementing the value in the field.
private var minusButton: ShapeButton
Small stepper/spin button for decrementing the value in the field.
private var callback: Function
Callback function called when the field has been changed.
private var stepColor: uint
Base theme color of the stepper buttons
public var precision: int
Number of fractional decimal digits shown
public var step: Number
Step size used when incrementing/decrementing
public var minimum: Number
The smallest value that the field will be decremented to.
public var maximum: Number
The largest value that the field will be incremented to.
public function NumberInput(owner: String,  
labelText: String = null,
inputValue: Number = 0.0,
changeHandler: Function = null,
useStepper: Boolean = true,
stepperColor: uint = Color.Grey,
labelWidth: uint = DEFAULT_LABEL_WIDTH,
inputWidth: uint = DEFAULT_INPUT_WIDTH,
color: uint = defaultColor,
fontSize: uint = defaultFontSize)
Creates a floating point number input field with an optional label and optional auto-repeating stepper buttons.
public function get value():Number
Get the numeric value from the field.
private function increment():void
Increments the field value when the user clicks or auto-repeats the up stepper button by keeping it pressed.
private function decrement():void
Decrements the field value when the user clicks or auto-repeats the down stepper button by keeping it pressed.
private function inputChangeHandler(event: Event):void
Triggers a set change callback when the text in the input field has been changed.
public function set active(state: Boolean):void
Sets the state of the widget to active or inactive.
private function activate():void
Activates the widget, adds its event listeners
private function disactivate():void
Disactivates the widget, removes its event listeners
public function dispose():void
Dispose of all resources used or referenced in the instance.
private function destructor():void
Removes used resources, references and graphics
An integer number input field with an optional label and optional auto-repeating stepper buttons.
A one line text input field with an optional label.
public function register(owner: String):void
Register the owner of a widget.
Close