This content has been marked as final. Show 4 replies
Or even understand what I just posted?!? ;-)
If the scroll bar automatically adjusts its own height due to some of your other AS, then use this code. Put it into the scrollbar's movieclip. (or modify it to how it fits)
furthestPoint is how far down it can go, basically, set this to how big the window is
startingPoint is where it starts, set this to where the window starts (or something) play around, you'll understand
In mouseDown part, if(this.hitTest(_root._xmouse,_root._ymouse,true)) is just how I make to check if you clicked on a movie clip.
this.startDrag(false,_x,_height/2+startingPoint,_x,furthestPoint-_height/2+startingPoint) is how it starts dragging.
[param 1] It doesn't lock the mouse to the center of the movieclip
[param 2] It makes it so the maximum place it can go left is _x
[param 3] It makes it so that's the maximum point it can move up
[param 4] It makes it so the maximum place it can go right is _x (with param 2 like that, it makes it stationary in _x)
[param 5] It makes it so that's the maximum point it can move down
and when you let go of your mouse, it "this.stopDrag()" or stops dragging.
I'm working to locate where (percent-wise) the bar is. Please wait.
Ok, use this:
to find where the scrollbar is in percentage to how much it can go.
i don't think you want to do what you just stated you want to do. that is, it makes no sense to snap the slider to another positions after a stopDrag(). though, you may want to snap your pictures to a particular position.
your slider can move from one extreme position to another. when your slider is at one extreme, your pictures are at one extreme (of one or more of their properties, usually their _x or _y property) and when your slider is at its other extreme, your pictures are at their other extreme. when the slider is between the two extreme positions, the pictures are between their extremes. usually, linear interpolation is used to set the picture's position based on the slider's position and this requires solving 2 (linear) equations in two unknowns.
for example, if your slider moves from sliderMin to sliderMax and your pictures are to scroll from picsMin to picsMax, you solve:
picsMin=sliderMin*a + b;
and now your picsPosition is given by:
picsPosition=sliderPosition*a + b;