Represent a ScrollBar in flash.
A ScrollBar
is totally virtual ! It provides you all the methods
to calculate and move your content as you want to. All the graphical components are let to you ! You
can link your graphical elements for the scroll management with the following methods :
Although the ScrollBar
class provides you some methods to easly link the content to be
managed :
The code beside shows how to create a classical vertical scrollbar associated with his buttons
Using :
var myScrollBar:ScrollBar = ScrollBar.create(this.content, this.mask, ScrollType.VERTICAL);
//set the buttons
var btnUp:ScrollClickButton = myScrollBar.getUpButton(this.up);
var btnDn:ScrollClickButton = myScrollBar.getDownButton(this.down);
var scroller:ScrollDragButton = myScrollBar.getScroller(this.scroller, this.scrollerBar, ScrollType.VERTICAL);
//a button that scroll with 10 pixels
//var simpleBtn:ScrollClickButton = myScrollBar.getClickButton(this.up, 10); //up button
//var simpleBtn:ScrollClickButton = myScrollBar.getClickButton(this.down, -10); //down button
//wheel button with a scroll of 10 pixels
//var wheel1:ScrollWheelButton = myScrollBar.getWheelButton(this.content, false, 10);
//wheel button with the delta scroll value
//var wheel2:ScrollWheelButton = myScrollBar.getWheelButton(this.content, false);
//wheel button with the default scroll value
var wheel3:ScrollWheelButton = myScrollBar.getWheelButton(this.content, true);
public function ScrollBar(model:ScrollBarModel)
Create a new ScrollBar.
model | The model. |
Error | If model is null .
|
public defaultScrollValue:Number
By default this value is 4.
static public function create(target:MovieClip, mask:MovieClip, type:ScrollType, setMaskDynamically:Boolean):ScrollBar
Create a new ScrollBar
.
target | The clip container. |
mask | The mask of the target. |
type | The ScrollType to use.
|
setMaskDynamically | Indicates if the mask must be set dynamically (using the setMask method).
false by default.
|
A new ScrollBar
.
static public function createFromScrollManager(scm:ScrollManager):ScrollBar
Create a new ScrollBar
.
scm | ScrollManager to use.
|
A new ScrollBar
.
public function setModel(model:ScrollBarModel):Void
Set the model of the scroll bar.
model | The model. |
Error | If model is null .
|
public function getClickButton(clip:MovieClip, scrollValue:Number):ScrollClickButton
Get a button associated with this ScrollBar
.
clip | The clip to be set as button. |
scrollValue | The scroll value of the ScrollClickButton .
|
A new ScrollClickButton
associated with this ScrollBar
.
public function getUpButton(clip:MovieClip):ScrollClickButton
Get an up/right button associated with this ScrollBar
with the default scroll value.
clip | The clip to be set as button. |
A new ScrollClickButton
associated with this ScrollBar
.
public function getDownButton(clip:MovieClip):ScrollClickButton
Get a down/left button associated with this ScrollBar
with the negative default scroll value.
clip | The clip to be set as button. |
A new ScrollClickButton
associated with this ScrollBar
.
public function getWheelButton(clip:MovieClip, useDefaultScrollValue:Boolean, scrollValue:Number):ScrollWheelButton
Get a ScrollWheelButton
associated with this ScrollBar
.
The clip
corresponds to the clip that will be checked when the
ch.component.scrollbar.ScrollWheelButton.onWheelMouse() method will be called.
There is three ways to use this method :
sc.getWheelButton(clip, true); //will use the ScrollBar.defaultScrollValue
sc.getWheelButton(clip, false); //will use the delta of Mouse.onMouseWheel
sc.getWheelButton(clip, false, 10); //will use the value (10)
clip | The clip that will be used for the manager. |
useDefaultScrollValue | A value specifing if the defaultScrollValue will
be used instead of the delta of the mouse wheel. By default,
this value is true .
|
scrollValue | A value specifing the number of pixel to scroll or null .
|
A new ScrollWheelButton
associated with this ScrollBar
.
public function getScroller(scroller:MovieClip, background:MovieClip, type:ScrollType, backgroundScrollValue:Number, autoSize:Boolean):ScrollDragButton
Get a scroller associated with this ScrollBar
.
A scroller is composed of two parts : the scroller that you can move and the delimiter (background of the scroller).
By default, the backgroundScrollValue
of the ScrollDragButton
is
defaultScrollValue*3
.
scroller | The scroller. |
background | The background of the scroller. |
type | The ScrollType to use.
|
backgroundScrollValue | The background scroll value or null . If this value is <= 0, the scroller
goes directly to the mouse position.
|
autoSize | Defines if the scroller is automatically resized or not depending on the content. |
A new ScrollDragButton
associated with this ScrollBar
.
public function getHandButton(Void):ScrollHandButton
Get a hand button linked to the content of this ScrollBar
and the
ScrollManager
of the content.
Note that the ScrollHandButton
created by this method will only
allows the drag of the content on one side (horizontal or vertical).
A new ScrollHandButton
associated with the ScrollBarModel
of this ScrollBar
.