Invert your equation.
If your scrollbar has a percentage from 0-1 where 0 is left and 1 is right, then
do this:
content.x = content.width * (1 - scrollbar.perc);
This is just for example. Obviously you would need to account for content not
starting at 0. But you get the idea. It's pretty simple to invert.
thomas horner wrote:
ok this is more of a maths issue, which i'm bloody useless at! i have a
horizontal left to right scroller and basically want it to do the opposite
and scroll from right to left,
i have positioned my content holder at stage.stageWidth and am position my
content in the loop by subtracting.
but am a bit stuck;
public var contentAreaX:int = 0;
public var scrollbarX:int=0;
public var scrollbarY:int=0;
public var xOffset:Number;
public var xMin:Number=0;
public var xMax:Number=0;
public var sp:Number;
xMax = stage.stageWidth - scroller.scrollbar.thumb.width;
stage.addEventListener(Event.RESIZE, resizeHandler);
stage.dispatchEvent(new Event(Event.RESIZE))
scroller.scrollbar.x = scrollbarX;
scroller.scrollbar.y = scrollbarY;
//what happens when you click the scrollbar thumb
function thumbDown(e:MouseEvent):void {
stage.addEventListener(MouseEvent.MOUSE_MOVE, thumbMove);
xOffset = mouseX -
scroller2.scrollbar.thumb.x;
}
//what happens when you release the
scrollbar thumb
function thumbUp(e:MouseEvent):void {
stage.removeEventListener(MouseEvent.MOUSE_MOVE, thumbMove);
}
//what happens when you move the scrollbar
thumb
function thumbMove(e:MouseEvent):void {
scroller2.scrollbar.thumb.x = mouseX -
xOffset;
xMax = stage.stageWidth -
scroller2.scrollbar.thumb.width;
if (scroller2.scrollbar.thumb.x <= xMin) {
scroller2.scrollbar.thumb .x = xMin;
}
if (scroller2.scrollbar.thumb.x >= xMax) {
scroller2.scrollbar.thumb.x = xMax;
}
var sp:Number = scroller2.scrollbar.thumb.x
/ xMax;
TweenMax.to(scroller2.holder, 0.6, { x:(sp *
(stage.stageWidth - (scroller2.holder.width + (contentAreaX * 2)))),
ease:Quad.easeOut} );
e.updateAfterEvent();
}
//what happens when you click somewhere
along the scrollbar track
function moveThumb(e:MouseEvent):void {
sp = mouseX / xMax;
if (mouseX >= (scroller2.scrollbar.thumb.x +
scroller2.scrollbar.thumb.width) ) {
TweenMax.to(scroller2.scrollbar.thumb, 1.0,
{ x:(mouseX - scroller2.scrollbar.thumb.width), ease:Quad.easeOut } );
sp = (mouseX -
scroller2.scrollbar.thumb.width) / xMax;
} else {
TweenMax.to(scroller2.scrollbar.thumb, 1.0,
{ x:mouseX, ease:Quad.easeOut } );
sp = mouseX / xMax;
}
TweenMax.to(scroller2.holder, 1.0, { x:(sp *
((stage.stageWidth) - scroller2.holder.width)), ease:Quad.easeOut } );
}
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders