Scrollbar |
Scrollbar widget. The current implementation is a vertical scrollbar suitable for scrolling a multiline text field up and down. Scroll events can be generated and handled from mouse clicks, drags and programatically from events such as mouse wheel rolls in a text field.
See ScriptField for an example of a widget using the scrollbar.
Scrollbar | Scrollbar widget. |
Public static constants | |
DEFAULT_WIDTH | Width of the scrollbar |
Private constants | |
DEFAULT_HEIGHT | Height of the scrollbar buttons and slider |
Private positional members | |
curPos | Current position of the scrollbar slider |
minPos | Minimum position of the scrollbar slider |
maxPos | Maximum position of the scrollbar slider |
incPos | Increment/decrement used when the up/down buttons are clicked |
Private display members | |
background | Scrollbar background area. |
upButton | Scrollbar up button. |
downButton | Scrollbar down button. |
slider | Scrollbar slider. |
Private data members | |
backHeight | Height of the background area (includes buttons). |
callback | Callback function called when the scrollbar changes position |
isDragging | Set to true when the slider is being dragged |
Constructor | |
Scrollbar | Creates a vertical scrollbar suitable for a multiline text field. |
Positional methods | |
setMinMax | Sets the minimum and maximum values for the scrollbar. |
positionSlider | Changes the slider position to the new position which must be in the min/max interval. |
positionSliderMouseRelative | Calculates a new slider position based on the mouse y position relative to the slider background and updates the slider position accordingly. |
Widget event methods | |
moveUp | Called when the upButton is clicked, causes the slider position to be incremented. |
moveDown | Called when the downButton is clicked, causes the slider position to be incremented. |
Mouse event methods | |
onMouseDown | Called when the mouse is button is pressed down. |
onMouseMove | Called when the mouse is moved over the scrollbar. |
onMouseUp | Called when the mouse is button is released. |
onMouseOut | Called when the mouse is moved outside a scrollbar sprite. |
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 Scrollbar( owner: String, height: uint, minValue: Number, maxValue: Number, increment: Number, positionHandler: Function, frontColor: uint = Color.Grey, backColor: uint = Color.DarkGrey )
Creates a vertical scrollbar suitable for a multiline text field.
owner | name of registered owner (see <WidgetSprite.register>) |
height | height of the scrollbar in pixels |
minValue | minimum (top) value |
maxValue | maximum (bottom) value |
increment | value added or subtracted from the current position when the up/down buttons are used |
positionHandler | a callback function that is called when the scrollbar position is changed |
frontColor | base theme color for the buttons and slider |
backColor | base theme color for the background |
positionHandler | function onScrollbarPositionChange(newPosition:Number):void |
private function moveUp():void
Called when the upButton is clicked, causes the slider position to be incremented.
private function moveDown():void
Called when the downButton is clicked, causes the slider position to be incremented.
Width of the scrollbar
public static const DEFAULT_WIDTH: uint
Height of the scrollbar buttons and slider
private const DEFAULT_HEIGHT: uint
Current position of the scrollbar slider
private var curPos: Number
Minimum position of the scrollbar slider
private var minPos: Number
Maximum position of the scrollbar slider
private var maxPos: Number
Increment/decrement used when the up/down buttons are clicked
private var incPos: Number
Scrollbar background area.
private var background: Sprite
Scrollbar up button.
private var upButton: ShapeButton
Scrollbar down button.
private var downButton: ShapeButton
Scrollbar slider.
private var slider: Sprite
Height of the background area (includes buttons).
private var backHeight: uint
Callback function called when the scrollbar changes position
private var callback: Function
Set to true when the slider is being dragged
private var isDragging: Boolean
Creates a vertical scrollbar suitable for a multiline text field.
public function Scrollbar( owner: String, height: uint, minValue: Number, maxValue: Number, increment: Number, positionHandler: Function, frontColor: uint = Color.Grey, backColor: uint = Color.DarkGrey )
Sets the minimum and maximum values for the scrollbar.
public function setMinMax( minValue: Number, maxValue: Number ):void
Changes the slider position to the new position which must be in the min/max interval.
public function positionSlider( newPosition: Number ):void
Calculates a new slider position based on the mouse y position relative to the slider background and updates the slider position accordingly.
private function positionSliderMouseRelative():void
Called when the upButton is clicked, causes the slider position to be incremented.
private function moveUp():void
Called when the downButton is clicked, causes the slider position to be incremented.
private function moveDown():void
Called when the mouse is button is pressed down.
private function onMouseDown( event: MouseEvent ):void
Called when the mouse is moved over the scrollbar.
private function onMouseMove( event: MouseEvent ):void
Called when the mouse is button is released.
private function onMouseUp( event: MouseEvent ):void
Called when the mouse is moved outside a scrollbar sprite.
private function onMouseOut( 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