Packagegs.display
Classpublic final class ScrollBar

The ScrollBar class provides vertical and horizontal scrolling.


Example
Setting up the scrollbar:
 
  var scrollBar:ScrollBar = new ScrollBar(stage,content,contentMask,handle,track,upArrow,downArrow);
  var scrollBar2:ScrollBar = new ScrollBar(stage,content2,contentMask2,handle2,track2,leftArrow,rightArrow,ScrollBar.HORIZONTAL);
  

If the content clip contains only one textfield, and the autoSize property is set to "none," the scrollbar set's it to "left" otherwise the height of the content clip is incorrect.

The ScrollBar uses initial property values from the clips you provide, to calculate offsets, max y, and min y, and also for resetting. So the clips must be laid out exactly how they are to be used. Otherwise you'll see weird offsets, which aren't correct.

Examples are in the guttershark repository.



Public Properties
 PropertyDefined by
  allowTrackClick : Boolean
Whether or not to allow track clicks.
ScrollBar
  arrowsStep : Number = 5
The amount of pixels to move the handle, when the up, down, left or right arrow is clicked.
ScrollBar
  direction : String
The scroll direction, can be ScrollBar.VERTICAL (default), or ScrollBar.HORIZONTAL.
ScrollBar
  easeSpeed : Number = .4
Scrolling ease speed.
ScrollBar
  wheelStep : Number = 5
The amount of pixels to move the handle, when the mouse wheel is used.
ScrollBar
Public Methods
 MethodDefined by
  
ScrollBar(stage:Stage, content:Sprite, contentMask:Sprite, handle:Sprite, track:Sprite, upOrLeftArrow:Sprite = null, downOrRightArrow:Sprite = null, direction:String = "vertical", allowTrackClick:Boolean = true, autoScrollOnArrowsDown:Boolean = true)
Constructor for ScrollBar instances.
ScrollBar
  
dispose():void
Dispose of this scroll bar.
ScrollBar
  
Resets the handle x and y position to the very first positions that were used when the scrollbar was created, but does not trigger a scroll update.
ScrollBar
Public Constants
 ConstantDefined by
  HORIZONTAL : String = "horizontal"
[static] Horizontal scrollbar mode.
ScrollBar
  VERTICAL : String = "vertical"
[static] Vertical scrollbar mode.
ScrollBar
Property detail
allowTrackClickproperty
public var allowTrackClick:Boolean

Whether or not to allow track clicks.

arrowsStepproperty 
public var arrowsStep:Number = 5

The amount of pixels to move the handle, when the up, down, left or right arrow is clicked.

directionproperty 
direction:String  [read-write]

The scroll direction, can be ScrollBar.VERTICAL (default), or ScrollBar.HORIZONTAL.

Implementation
    public function get direction():String
    public function set direction(value:String):void
easeSpeedproperty 
public var easeSpeed:Number = .4

Scrolling ease speed.

wheelStepproperty 
public var wheelStep:Number = 5

The amount of pixels to move the handle, when the mouse wheel is used.

Constructor detail
ScrollBar()constructor
public function ScrollBar(stage:Stage, content:Sprite, contentMask:Sprite, handle:Sprite, track:Sprite, upOrLeftArrow:Sprite = null, downOrRightArrow:Sprite = null, direction:String = "vertical", allowTrackClick:Boolean = true, autoScrollOnArrowsDown:Boolean = true)

Constructor for ScrollBar instances.

Parameters
stage:Stage — A stage reference, needed for mouse events.
 
content:Sprite — The content clip.
 
contentMask:Sprite — The content mask clip.
 
handle:Sprite — The scrollbar handle clip.
 
track:Sprite — The scrollbar track clip.
 
upOrLeftArrow:Sprite (default = null) — An arrow button that causes up or left scrolling.
 
downOrRightArrow:Sprite (default = null) — An arrow button that causes down or right scrolling.
 
direction:String (default = "vertical") — The direction for scrolling, horizontal or vertical.
 
allowTrackClick:Boolean (default = true) — Whether or not to allow clicking on the scroll track.
 
autoScrollOnArrowsDown:Boolean (default = true) — Whether or not to auto scroll when the mouse is pressed down, and held, over an arrow button.
Method detail
dispose()method
public function dispose():void

Dispose of this scroll bar.

resetHandlePosition()method 
public function resetHandlePosition():void

Resets the handle x and y position to the very first positions that were used when the scrollbar was created, but does not trigger a scroll update.

Constant detail
HORIZONTALconstant
public static const HORIZONTAL:String = "horizontal"

Horizontal scrollbar mode.

VERTICALconstant 
public static const VERTICAL:String = "vertical"

Vertical scrollbar mode.