Manager of content that can be scrolled.
public function ScrollBarModel(scrollManager:ScrollManager)
Create a new ScrollBarModel.
The ScrollManager
is the manager that will be used
for the scroll calculation and the position adjustment. So the
target
of the ScrollManager
should be the content and the
delimiter
should be the mask.
scrollManager | The ScrollManager to use.
|
Error | If scrollManager is null .
|
public onScroll:Function
Prototype :
scb.onScroll = function(eventSource:Object, scrolled:Number, ratio:Number, position:Number, refreshOnly:Boolean):Void { }
public function addListener(listener:ScrollListener):Void
Add a listener.
listener | The listener to add. |
public function removeListener(listener:ScrollListener):Void
Remove a listener.
listener | The listener to remove. |
public function getScrollManager(Void):ScrollManager
Get the ScrollManager
of the model.
Note that if you call directly a method from the ScrollManager
,
the events won't be dispatched. It may cause problems on the listeners of
the ScrollBarModel
.
The ScrollManager
public function setScrollManager(scrollManager:ScrollManager, fireEvent:Boolean):Void
Set the ScrollManager
of the ScrollBarModel
.
If the fireEvent
is true
, an event scrollPerformed
will
be dispatched to the listeners, so they can update them to the current state of
the new ScrollManager
. The scroll value will be 0.
scrollManager | The new ScrollManager .
|
fireEvent | true to dispatch the event.
|
Error | If scrollManager is null .
|
public function setMargins(topLeft:Number, bottomRight:Number):Void
Set the margins of the ScrollManager
.
This method set margin1
and margin2
into the
ScrollManager
and call the adjust
method with a
ratio of 0 to reset the ScrollBar
.
If you want to manually set the margins and readjust the ScrollBar
,
simply get the ScrollManager
, set margin1
and margin2
, and
finally call the adjust
method within your own ratio.
topLeft | The top/left margin (depend of the ScrollBarModel type).
|
bottomRight | The bottom/right margin (depend of the ScrollBarModel type).
|
public function scroll(value:Number, source:Object):Number
Scroll the target clip relatively with the specified value.
This method checks automatically the value to scroll. If the value is too big (or small), the it is automatically adjusted to scroll the exact value to reach the maximum (or minimum point). If this method returns 0, then no more scroll is available in the same direction.
The direction of the scroll is determinated by the sign of value
. If
value
is less thant 0, then the content clip will be scrolled down. It means
that it has the same effect as if you click the up arrow on a classical scroll bar.
value | The value to scroll. |
source | The object that is changing the scroll or null .
|
The number of pixels scrolled.
public function adjust(ratio:Number, source:Object):Number
Adjust the scroll within the specified ratio.
This method ajust the content to the mask at the specified ratio. The ratio of the content position is calculated on the size of the content minus the size of the mask.
Since the version 1.8.1 the ratio value is automatically adjusted to 0 if the value is less than 0 and to 1 if the value is greater than 1.
ratio | A Number between 0 and 1 inclusive.
|
source | The object who is adjusting the scroll or null .
|
The number of pixels scrolled.
public function refresh(source:Object, updateContent:Boolean):Void
Refresh the ScrollBarModel
.
This method simply dispatch an event where
the scroll value is 0. This will update all the
listeners of the ScrollBarModel
. Note
that you can use this method when you update the
content position directly ! It is important to not
have tweens working on the content when you call
this method, because the positions will not be correct.
source | The source object that perform the refresh or null .
|
updateContent | Indicates if the content must be moved when it is out of bounds (false by default). |
public function isScrollable(Void):Boolean
Get if the content can be scrolled.
If this method returns false
, then a ScrollBar is
not useful because the content can be completely shown in the mask.
true
if a ScrollBar is needed.
public function fireScrollPerformed(scrolled:Number, source:Object, refreshOnly:Boolean):Void
Dispatch the scrollPerformed
event to the listeners.
This method is conceptually public in order to be called
by the subclasses ! It should not be called by the other classes.
Use the refresh
method in place.
scrolled | The number of pixels scrolled. |
source | The object performing the event or null .
|