|
-
trying to get a vertical scrollbar to scroll a movieclip problem, help needed!...
Hi guys
I'm trying to create a scrollbar for a movieclip
Basically when i move the scrollbar down the content movieclip should go up and vice versa,
This works, however I can't get the scrolling to stop exactly at the bottom of the content movieclip, and its turning me a bit nuts. (theres a little blue square at the bottom of the content movieclip, and that should be displayed when the scroller has reached the bottom, but it isnt :-( )
the example fla can be downloaded here:
http://www.joeprice.co.uk/temp/scrollBarProblem.fla
If anyone could have a look and try to solve the problem i'd be most grateful!
Cheers
Joe
-
If you don't plan to make the scrollbar dynamic then this is the quick fix:
_root.joesContent._y = -_root.slider._y*1.66 ;
Otherwise it's a math problem to move the content in relation to the scrollbar position and the height of the content mask
-
in human terms, scrolling is done like so:
target's vertical position = - ( target's height - path's height ) * dragger's position + ( dragger's height * ( ( dragger's position + dragger's height ) / path's height ) ) / path's height;
-
here's a basic e.g.,code: function empty(a){
var b=a.getNextHighestDepth();
return a.createEmptyMovieClip(b,b);}
MovieClip.prototype.fill=function(){
beginFill.apply(this,arguments);
for(var b=4;--b;)this.lineTo(b>1,b<3);
this.endFill();
return this;}
MovieClip.prototype.size=function(a,b){
this._width=a;
this._height=b;
return this;}
MovieClip.prototype.move=function(a,b){
this._x=a;
this._y=b;
return this;}
main=empty(this).move(20,20);
empty(main).fill(0xfafafa).size(210,300);
scrollee=empty(main);
while(scrollee._height<Stage.height*3)empty(scroll ee).move(0,scrollee._height+2).fill(0xff9900,scrol lee._height/Stage.height*33).size(20,20);
scroller=empty(this).move(220,20);
empty(scroller).fill(0xfafafa).size(10,300);
dragger=empty(scroller).fill(0xff9900).size(10,40) ;
dragger.onPress=function(){
this.startDrag(false,this._x,0,this._x,scroller._h eight-this._height);
this.onEnterFrame=function(){
scrollee._y =-scrollee._height*(dragger._y+(dragger._height*((dr agger._y+dragger._height)/scroller._height)))/scroller._height;}
this.onMouseUp=function(){
this.stopDrag();
delete this.onEnterFrame;
delete this.onMouseUp;}}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|