all groups > flash actionscript > february 2007 >
You're in the

flash actionscript

group:

Horizontal Scrollbar



Horizontal Scrollbar andrePT
2/1/2007 11:41:07 PM
flash actionscript: Hi everybody...i want to create a simple horizontal scroller for a movieclip
but i can´t find any good tutorials for it...im new at this and i was wondering
if someone could point me to some nice tutorials for this...all i find is
vertical scrollbars :S

thanks
Re: Horizontal Scrollbar kglad
2/2/2007 1:08:22 AM
there's no significant different between vertical and horizontal scrollbars.

instead of the tob and bottion you use the left-most and right-most extent of
the slider and the extremes of your scrolling object to create two linear
equations in 2 unknowns to calculate how much your scrolling object should
change with any change in your scrollbar.
Re: Horizontal Scrollbar andrePT
2/2/2007 11:16:50 AM
thanks for the help but i cannot get it to work...i am a newbie at AS and i
need to see an example of the code so i can study and understand! kglad....i
understand what u said, the theory, but i cannot put it in practice :(

i have this code from a vertical scrollbar that i changed...but it doesnt
work...i think its all wrong....can u guys help me out plz?

scrolling = function () {
var scrollWidth:Number = scrollTrack._width;
var contentWidth:Number = contentMain._width;
var scrollFacewidth:Number = scrollFace._width;
var maskWidth:Number = maskedView._width;
var initPosition:Number = scrollFace._x=scrollTrack._x;
var initContentPos:Number = contentMain._x;
var finalContentPos:Number = maskwidth-contentwidth+initContentPos;
var left:Number = scrollTrack._x;
var top:Number = scrollTrack._y;
var right:Number = scrollTrack._width-scrollFace._width+scrollTrack._x;
var bottom:Number = scrollTrack._y;
var dy:Number = 0;
var speed:Number = 10;
var moveVal:Number = (contentWidth-maskWidth)/(scrollWidth-scrollFaceWidth);

scrollFace.onPress = function() {
var currPos:Number = this._x;
startDrag(this, false, left, top, bottom, right);
this.onMouseMove = function() {
dy = Math.abs(scrollTrack_x-this._x);
contentMain._x = Math.round(dy*-1*moveVal+initContentPos);
}
}
scrollFace.onMouseUp = function() {
stopDrag();
delete this.onMouseMove;
}
}
scrolling();
AddThis Social Bookmark Button