Class ch.component.scrollbar.ScrollDragButton

Implemented Interfaces

ScrollBarManager ScrollListener

Description

Represent a button that manage a ScrollBar by being dragged.

Field Index

alwaysRefresh, alwaysResize, autoAdjust, autoHide, autoScroll, backgroundScrollValue, maximumSize, minimumSize, NORMAL_MODE, REVERSE_MODE, SPEED_SCROLL

Method Index

new ScrollDragButton()
getBackground(), getContentRatio(), getMode(), getRatio(), getScroller(), getType(), isBackgroundPressed(), isDragged(), onBackgroundPress(), onBackgroundRelease(), onBackgroundReleaseOutside(), onScrollerPress(), onScrollerRelease(), onScrollerReleaseOutside(), resize(), scrollPerformed(), scrollTo(), setEnabled(), setMode(), setRatio(), toString()

Inherited from AbstractScrollBarManager

Constructor Detail

ScrollDragButton

public function ScrollDragButton(scroller:MovieClip, scrollerBackground:MovieClip, type:ScrollType, backgroundScrollValue:Number, autoAdjust:Boolean, autoHide:Boolean, alwaysResize:Boolean, alwaysRefresh:Boolean)

Create a new ScrollDragButton.

Parameters

scrollerThe clip scroller.
typeThe ScrollType to use.
backgroundScrollValueScroll value on the press on the background (<=0 means that the scroller scrolls directly to the mouse position).
autoAdjustIf the scroller should adjust automatically. ()
autoHideIf the scroller should automatically hide.
alwaysResizeIf the scroller should be resized at all events.
alwaysRefreshIf a refresh event must be dispatched when the mouse is pressed.

Throws

ErrorIf scroller is null.
ErrorIf scrollerBackground is null.
ErrorIf type is null.
ErrorIf backgroundScrollValue is null.

Field Detail

NORMAL_MODE

static public NORMAL_MODE:Number [Read Only]
Normal mode.

Constant value : 0.

REVERSE_MODE

static public REVERSE_MODE:Number [Read Only]
Reverse mode.

Constant value : 1.

SPEED_SCROLL

static public SPEED_SCROLL:Number [Read Only]
Determine the speed of the interval (in ms) to perform a scroll on the background when the autoScroll delay is over. The scroll value can be adjusted with the backgroundScrollValue variable.

Constant value : 40.

backgroundScrollValue

public backgroundScrollValue:Number
Scroll value on the background press.

Specifies the value to scroll when the user press on the background of the scroller.

If this value is less than or equal to 0, the scroller will be direct scrolled to the mouse position.

autoScroll

public autoScroll:Number
Time to wait before automatic scroll.

This value is linked with the TIME_SCROLL value. It specifies how many milliseconds to wait before the scroller is automatically scrolled when the user press the background.

By default, this value is 400.

minimumSize

public minimumSize:Number
Defines the minimum size of the scroller when the autoAdjust property is true.

maximumSize

public maximumSize:Number
Defines the maximum size of the scroller when the autoAdjust property is true.

autoAdjust

public autoAdjust:Boolean
Defines if the scroller should be adjusted automatically depending on the content size.

The size of the scroller will be set at the same ratio of the content whent the refresh() method will be invoked.

autoHide

public autoHide:Boolean
Defines if the scroller should automatically hide or not.

alwaysResize

public alwaysResize:Boolean
Defines if the scroller should be resized each time an actionPerformed event is performed or only when the event is a refresh event.

alwaysRefresh

public alwaysRefresh:Boolean
Defines if a refresh event must be dispatched when the mouse is pressed or only when the mouse is released.

Method Detail

setEnabled

public function setEnabled(value:Boolean):Void

Set if the ScrollDragButton is enabled or not.

Parameters

value true to enable the ScrollDragButton, false otherwise.

Overrides

setEnabled() in ch.component.scrollbar.AbstractScrollBarManager

getScroller

public function getScroller(Void):MovieClip

Get the scroller clip.

Return

The scroller.

getBackground

public function getBackground(Void):MovieClip

Get the background of the scroller.

Return

The background.

getType

public function getType(Void):ScrollType

Get the scroll type.

Return

The ScrollType used.

getMode

public function getMode(Void):Number

Get the mode.

Return

NORMAL_MODE or REVERSE_MODE.

setMode

public function setMode(mode:Number):Void

Set the mode.

The mode set how the ScrollDragButton must move. By normal mode, it will move up-down or left-right. By reverse mode, it will move down-up or right-left. This method automatically replace the scroller at his right place, depending on the current ratio, calling the setRatio method.

If the mode is the same as the current mode, nothing append.

Parameters

mode NORMAL_MODE or REVERSE_MODE.

Throws

ErrorIf mode is invalid.

scrollPerformed

public function scrollPerformed(event:ScrollEvent):Void

Method called when a scroll is performed on a ScrollBarModel.

Parameters

eventThe event object.

Specified By

scrollPerformed() in ch.component.scrollbar.ScrollListener

getContentRatio

public function getContentRatio(Void):Number

Get the size ratio between the content and the background.

Return

The size ratio of the content.

resize

public function resize(size:Number):Void

Resize the scroller to the specified size.

Parameters

sizeThe size for the scroller.

isDragged

public function isDragged(Void):Boolean

Get if this ScrollDragButton is being dragged.

Return

true if the scroller is being dragged.

isBackgroundPressed

public function isBackgroundPressed(Void):Boolean

Get if the background is pressed.

Return

true if the background is pressed.

setRatio

public function setRatio(ratio:Number):Void

Set the ratio of the scroller.

Calling this method won't affect the linked ScrollBar ! It only will move the scroller to the specified ratio, using the scrollTo method. When you want to adjust the ScrollBar linked to the ScrollDragButton, use the adjust method.

Note that a ScrollDragButton in NORMAL_MODE or in REVERSE_MODE will not be set at the same place within the same value. The ScrollDragButton in REVERSE_MODE will be automatically adjusted !

Parameters

ratioA Number between 0 and 1 inclusive.

See Also

getRatio

public function getRatio(Void):Number

Get the ratio of the scroller.

Note that a ScrollDragButton in NORMAL_MODE or in REVERSE_MODE will return the same value !

Return

A Number between 0 and 1 inclusive.

scrollTo

public function scrollTo(target:MovieClip, property:String, value:Number):Void

Scroll to the specified value. This method moves directly the target clip property to the specified valu.

Parameters

targetThe target clip.
propertyThe property to affect.
valueThe position.

onScrollerRelease

public function onScrollerRelease(Void):Void

Action onRelease of the clip.

onScrollerPress

public function onScrollerPress(Void):Void

Action onPress of the clip.

onScrollerReleaseOutside

public function onScrollerReleaseOutside(Void):Void

Action onReleaseOutside of the clip.

onBackgroundPress

public function onBackgroundPress(Void):Void

Action onPress of the background.

onBackgroundRelease

public function onBackgroundRelease(Void):Void

Action onRelease of the background.

onBackgroundReleaseOutside

public function onBackgroundReleaseOutside(Void):Void

Action onReleaseOutside of the background.

toString

public function toString(Void):String

Represent the current instance into a String.

Return

A String representing the ScrollDragButton instance.

Overrides

toString() in ch.component.scrollbar.AbstractScrollBarManager