Manage the scrolling of a MovieClip behind a mask.
This class manages the calculation of the scroll and the effect of the scroll. If you want to customize your scroll effects on the content, you can simply override the move(MovieClip,String,Number) method to set your personnal effect.
new ScrollManager()public function ScrollManager(target:MovieClip, delimiter:MovieClip, scrollType:ScrollType)Create a new ScrollManager.
The target represent the clip that will be behind the mask. The
delimiter is supposed to be the mask of the target. The
scrollType set the direction of the scroll.
target | The target clip. |
delimiter | The target clip delimiter (mask). |
scrollType | The ScrollType to use.
|
| Error | If target is null.
|
| Error | If delimiter is null.
|
public margin1:NumberBy default, this value is 0.
public margin2:NumberBy default, this value is 0.
public function getDelimiter(Void):MovieClipGet the target clip delimiter.
The clip delimiter.
public function setScrollType(type:ScrollType):VoidSet the scroll type to use on the target content.
type | The ScrollType to set.
|
| Error | If type is null.
|
public function init(Void):VoidInitilalize the content.
This method simply set the _x/_y position (depending on the scroll type) of
the content MovieClip. It is automatically called when the setScrollType
method is called.
public function getMinMove(Void):NumberGet the minimum allowed position.
The returned value is an integer rounded with Math.floor()
The minimum allowed position.
public function getMaxMove(Void):NumberGet the maximum allowed position.
The returned value is an integer rounded with Math.round()
The maximum allowed position.
public function getVirtualPosition(Void):NumberGet the virtual position of the content.
This position is the real position where the
target content should be. Instead of the getCurrentPosition method,
this method returns the real virtual position.
The virtual position.
public function getCurrentPosition(Void):NumberGet the current position of the target relatively to 0.
This method return the position where the target should be if the center point is 0.
A Number between 0 and getMaxMove()-getMinMove() inclusive.
public function setCurrentPosition(position:Number):NumberSet the current position of the target.
position | A Number between 0 and getMaxMove()-getMinMove()
inclusive.
|
The number of pixel scrolled.
| Error | If position is invalid.
|
public function updateCurrentPosition(updateContentPosition:Boolean):VoidUpdate the current position of the target.
This method simple take the current position of the
target. If you call it, it is recommended to stop all the
tweens in order to have the correct value. Note that if
the value of the target is lower that getMinMove() or
greater that getMaxMove(), the virtual position will be
set to the maximum or the minimum, so the ratio won't exceed 1 or
be lower thant 0 !
updateContentPosition | Indicates whethever the content position must be updated (false by default). |
public function getRealRatio(Void):NumberGet the current real ratio of the position between the target clip and the delimiter clip.
This method take the current position of the content. So if you have a Tween affecting it, the value returned by this method will be altered.
A Number between 0 and 1 inclusive.
public function getRatio(Void):NumberGet the ratio of the position between the target clip and the delimiter clip.
This method return the ratio calculated on the target virtual position. It means
that if a Tween is currently acting on the content MovieClip, your ratio
won't change : it will be calculated as if the content was on his final place.
public function setRatio(ratio:Number):NumberSet the ratio of the target.
ratio | A Number between 0 and 1 inclusive.
|
The number of pixels scrolled.
| Error | If ratio is invalid.
|
public function getContentRatio(Void):NumberGet the size ratio between the content and the background.
The size ratio of the content.
public function getAllowedScroll(value:Number):NumberGet the allowed scroll value.
If this method returns 0, then no more scroll is available in the specified position.
value | The number of pixels to scroll. |
The number of pixels that can be scrolled.
| Error | If value is null.
|
public function scroll(value:Number):NumberScroll the target clip relatively with the specified value.
This method checks automatically the value.
value | The value to scroll. |
The number of pixels scrolled.
public function move(target:MovieClip, property:String, valueToMove:Number):Void
Move the specified property of the specified target within
the specified valueToMove value.
By default, this method set the property of the target to
the virtual position.
target | The MovieClip to move.
|
property | The property to use for the moving ( _x or _y).
|
valueToMove | The number of pixels to move. |