Hey everyone, I was going over the custom scroll bar tutorial and tried changing the vertical scroll into a horizontal scroll. The left and right buttons seem to be working fine but the scroll handle referred to in the tutorial as scrollFace got a bit tricky for me. Any help would be great.
scrolling = function ()
{
var scrollWidth:Number = globalNav.scrollTrack._width;
var contentWidth:Number = globalNav.tab1.contentMain._width;
var scrollFaceWidth:Number = globalNav.scrollFace._width;
var maskWidth:Number = globalNav.tab1.maskedView._width;
var initPosition:Number = globalNav.scrollFace._x = globalNav.scrollTrack._x;
var initContentPos:Number = globalNav.tab1.contentMain._x;
var finalContentPos:Number = maskWidth - contentWidth + initContentPos;
var left:Number = globalNav.scrollTrack._y;
var top:Number = globalNav.scrollTrack._x;
var right:Number = globalNav.scrollTrack._y;
// scroll track width 803.1 - scroll width which is 23.9 + scrollTrack which is 24.8
var bottom:Number = globalNav.scrollTrack._width - scrollFaceWidth + globalNav.scrollTrack._x;
var dy:Number = 0;
var speed:Number = 20;
var moveVal:Number = (contentWidth - maskWidth) / (scrollWidth - scrollFaceWidth);
globalNav.scrollFace.onPress = function ()
{
//trace (this._name);
trace(this._x)
var currPos:Number = this._x;
startDrag (this, false, left, top, right, bottom);
this.onMouseMove = function ()
{
dy = Math.abs (initPosition - this._x);
globalNav.tab1.contentMain._x = Math.round (dy * -1 * moveVal + initContentPos);
};
};
globalNav.scrollFace.onMouseUp = function ()
{
stopDrag ();
delete this.onMouseMove;
};
globalNav.sLeftBtn.onPress = function ()
{
this.onEnterFrame = function ()
{
if (globalNav.tab1.contentMain._x + speed < globalNav.tab1.maskedView._x)
{
if (globalNav.scrollFace._x <= top)
{
globalNav.scrollFace._x = top;
}
else
{
globalNav.scrollFace._x -= speed / moveVal;
}
globalNav.tab1.contentMain._x += speed;
}
else
{
globalNav.scrollFace._x = top;
globalNav.tab1.contentMain._x = globalNav.tab1.maskedView._x;
delete this.onEnterFrame;
}
};
};
globalNav.sLeftBtn.onDragOut = function ()
{
delete this.onEnterFrame;
};
globalNav.sLeftBtn.onRelease = function ()
{
delete this.onEnterFrame;
};
globalNav.sRightBtn.onPress = function ()
{
this.onEnterFrame = function ()
{
if (globalNav.tab1.contentMain._x - speed > finalContentPos)
{
if (globalNav.scrollFace._x >= bottom)
{
globalNav.scrollFace._x = bottom;
}
else
{
globalNav.scrollFace._x += speed / moveVal;
}
globalNav.tab1.contentMain._x -= speed;
}
else
{
globalNav.scrollFace._x = bottom;
globalNav.tab1.contentMain._x = finalContentPos;
delete this.onEnterFrame;
}
};
};
globalNav.sRightBtn.onRelease = function ()
{
delete this.onEnterFrame;
};
globalNav.sRightBtn.onDragOut = function ()
{
delete this.onEnterFrame;
};
if (contentWidth < maskWidth)
{
globalNav.scrollFace._visible = false;
globalNav.sLeftBtn.enabled = false;
globalNav.sRightBtn.enabled = false;
}
else
{
globalNav.scrollFace._visible = true;
globalNav.sLeftBtn.enabled = true;
globalNav.sRightBtn.enabled = true;
}
};
scrolling ();