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.
public alwaysRefresh:Boolean
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.
content | The target clip to drag. |
hModel | The ScrollBarModel of the horizontal scrollbar.
|
vModel | The ScrollBarModel of the vertical scrollbar.
|
The ScrollHandButton
created.
public function getContent(Void):MovieClip
Get the content to be scrolled.
The content.
public function setEnabled(value:Boolean):Void
Enable or disable the content.
value | true to enable the content, false otherwise.
|
setEnabled() in ch.component.scrollbar.AbstractScrollBarManager
public function scrollPerformed(event:ScrollEvent):Void
Method called when a scroll is performed on a
ScrollBarModel
.
event | The event object. |
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.
vScrollManager | The vertical ScrollManager or null .
|
Error | If vScrollManager is not ch.component.scrollbar.ScrollType.VERTICAL.
|
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.
hScrollManager | The horizontal ScrollManager or null .
|
Error | If hScrollManager is not ch.component.scrollbar.ScrollType.HORIZONTAL.
|
public function getVerticalScrollManager(Void):ScrollManager
Get the vertical scroll manager.
The vertical ScrollManager
.
public function getHorizontalScrollManager(Void):ScrollManager
Get the horizontal scroll manager.
The horizontal ScrollManager
.
public function onContentRelease(Void):Void
Method called when the content is released.
public function onContentReleaseOutside(Void):Void
Method called when the content is released outside.
This method simply call the onContentRelease
method.
public function toString(Void):String
Represent the current instance into a String.
A String representing the ScrollHandButton instance.
toString() in ch.component.scrollbar.AbstractScrollBarManager