Class ch.component.scrollbar.ScrollHandButton

Implemented Interfaces

ScrollBarManager ScrollListener

Description

Manage the drag of a content.

This class allows you to set the content of a ScrollBar being dragged in the predefined positions (margins included). You have many ways to implement the dragging of the content with this class.
var verticalSB:ScrollBar = ScrollBar.create(this.clipContent, this.clipMask, ScrollType.VERTICAL);
var horizontalSB:ScrollBar = ScrollBar.create(this.clipContent, this.clipMask, ScrollType.HORIZONTAL);

//create the scrollers, etc.

var shb:ScrollHandButton = ScrollHandButton.createAsContentPane(this.clipContent, horizontalSB.getModel(), verticalSB.getModel());

You can use the MVC pattern to adjust the actions of your ScrollHandButton :
var verticalSB:ScrollBar = ScrollBar.create(this.clipContent, this.clipMask, ScrollType.VERTICAL);
var horizontalSB:ScrollBar = ScrollBar.create(this.clipContent, this.clipMask, ScrollType.HORIZONTAL);

var shb:ScrollHandButton = new ScrollHandButton(this.clipContent);
shb.setHorizontalScrollManager(horizontalSB.getModel().getScrollManager()); //used to have the left/right coordinates
shb.setVerticalScrollManager(verticalSB.getModel().getScrollManager()); //used to have the top/bottom coordinates

//the event is dispatched to both models
shb.addScrollBarModel(horizontalSB.getModel());
shb.addScrollBarModel(verticalSB.getModel());

Note that a ScrollHandButton allows you to use only 2 types of ScrollType : Horizontal and Vertical. Thoses properties are used to define the rectangle where the content can be dragged.

See Also

Field Index

alwaysRefresh

Method Index

new ScrollHandButton()
createAsContentPane(), getContent(), getHorizontalScrollManager(), getVerticalScrollManager(), onContentPress(), onContentRelease(), onContentReleaseOutside(), scrollPerformed(), setEnabled(), setHorizontalScrollManager(), setVerticalScrollManager(), toString()

Inherited from AbstractScrollBarManager

Constructor Detail

ScrollHandButton

public function ScrollHandButton(content:MovieClip, alwaysRefresh:Boolean)

Create a new ScrollHandButton.

Parameters

contentThe MovieClip to be dragged.
alwaysRefreshDefines if the refresh event sould be dispatched when the mouse is pressed.

Throws

ErrorIf content is null.

Field Detail

alwaysRefresh

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

Method Detail

createAsContentPane

static public function createAsContentPane(content:MovieClip, hModel:ScrollBarModel, vModel:ScrollBarModel):ScrollHandButton

Create a new ScrollHandButton as a content pane.

Within this method, it will create a ScrollHandButton managed by a vertical scrollbar and an horizontal scrollbar. It can be useful if you uste it for map dragging for example.

Parameters

contentThe target clip to drag.
hModelThe ScrollBarModel of the horizontal scrollbar.
vModelThe ScrollBarModel of the vertical scrollbar.

Return

The ScrollHandButton created.

getContent

public function getContent(Void):MovieClip

Get the content to be scrolled.

Return

The content.

setEnabled

public function setEnabled(value:Boolean):Void

Enable or disable the content.

Parameters

value true to enable the content, false otherwise.

Overrides

setEnabled() in ch.component.scrollbar.AbstractScrollBarManager

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

setVerticalScrollManager

public function setVerticalScrollManager(vScrollManager:ScrollManager):Void

Set the vertical scroll manager.

The vertical ScrollManager is used to retrieve the top/bottom coordinates of the content to be dragged.

Parameters

vScrollManagerThe vertical ScrollManager or null.

Throws

ErrorIf vScrollManager is not ch.component.scrollbar.ScrollType.VERTICAL.

setHorizontalScrollManager

public function setHorizontalScrollManager(hScrollManager:ScrollManager):Void

Set the horizontal scroll manager.

The horizontal ScrollManager is used to retrieve the left/right coordinates of the content to be dragged.

Parameters

hScrollManagerThe horizontal ScrollManager or null.

Throws

ErrorIf hScrollManager is not ch.component.scrollbar.ScrollType.HORIZONTAL.

getVerticalScrollManager

public function getVerticalScrollManager(Void):ScrollManager

Get the vertical scroll manager.

Return

The vertical ScrollManager.

getHorizontalScrollManager

public function getHorizontalScrollManager(Void):ScrollManager

Get the horizontal scroll manager.

Return

The horizontal ScrollManager.

onContentPress

public function onContentPress(Void):Void

Method called when the content is pressed.

onContentRelease

public function onContentRelease(Void):Void

Method called when the content is released.

onContentReleaseOutside

public function onContentReleaseOutside(Void):Void

Method called when the content is released outside.

This method simply call the onContentRelease method.

toString

public function toString(Void):String

Represent the current instance into a String.

Return

A String representing the ScrollHandButton instance.

Overrides

toString() in ch.component.scrollbar.AbstractScrollBarManager