Class ch.component.scrollbar.ScrollBar

Description

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

See Also

Field Index

defaultScrollValue

Method Index

new ScrollBar()
create(), createFromScrollManager(), getClickButton(), getDownButton(), getHandButton(), getModel(), getScroller(), getUpButton(), getWheelButton(), setModel(), toString()

Constructor Detail

ScrollBar

public function ScrollBar(model:ScrollBarModel)

Create a new ScrollBar.

Parameters

modelThe model.

Throws

ErrorIf model is null.

Field Detail

defaultScrollValue

public defaultScrollValue:Number
Default scroll value for the buttons.

By default this value is 4.

Method Detail

create

static public function create(target:MovieClip, mask:MovieClip, type:ScrollType, setMaskDynamically:Boolean):ScrollBar

Create a new ScrollBar.

Parameters

targetThe clip container.
maskThe mask of the target.
typeThe ScrollType to use.
setMaskDynamicallyIndicates if the mask must be set dynamically (using the setMask method). false by default.

Return

A new ScrollBar.

createFromScrollManager

static public function createFromScrollManager(scm:ScrollManager):ScrollBar

Create a new ScrollBar.

Parameters

scm ScrollManager to use.

Return

A new ScrollBar.

setModel

public function setModel(model:ScrollBarModel):Void

Set the model of the scroll bar.

Parameters

modelThe model.

Throws

ErrorIf model is null.

getModel

public function getModel(Void):ScrollBarModel

Get the model.

Return

The model.

getClickButton

public function getClickButton(clip:MovieClip, scrollValue:Number):ScrollClickButton

Get a button associated with this ScrollBar.

Parameters

clipThe clip to be set as button.
scrollValueThe scroll value of the ScrollClickButton.

Return

A new ScrollClickButton associated with this ScrollBar.

getUpButton

public function getUpButton(clip:MovieClip):ScrollClickButton

Get an up/right button associated with this ScrollBar with the default scroll value.

Parameters

clipThe clip to be set as button.

Return

A new ScrollClickButton associated with this ScrollBar.

See Also

getDownButton

public function getDownButton(clip:MovieClip):ScrollClickButton

Get a down/left button associated with this ScrollBar with the negative default scroll value.

Parameters

clipThe clip to be set as button.

Return

A new ScrollClickButton associated with this ScrollBar.

See Also

getWheelButton

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)

Parameters

clipThe clip that will be used for the manager.
useDefaultScrollValueA value specifing if the defaultScrollValue will be used instead of the delta of the mouse wheel. By default, this value is true.
scrollValueA value specifing the number of pixel to scroll or null.

Return

A new ScrollWheelButton associated with this ScrollBar.

getScroller

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.

Parameters

scrollerThe scroller.
backgroundThe background of the scroller.
typeThe ScrollType to use.
backgroundScrollValueThe background scroll value or null. If this value is <= 0, the scroller goes directly to the mouse position.
autoSizeDefines if the scroller is automatically resized or not depending on the content.

Return

A new ScrollDragButton associated with this ScrollBar.

getHandButton

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).

Return

A new ScrollHandButton associated with the ScrollBarModel of this ScrollBar.

toString

public function toString(Void):String

Represent the current instance into a String.

Return

A String representing the ScrollBar instance.