Hello everyone,
I am building a project which has dynamic textfields.
I have created a custom scrollbar and I need some code editing in order to make it scroll the [COLOR=Red]text itself[/COLOR](instead of the dynamic textfield’s height) which is loaded inside the dynamic textfield through an xml file.(dynamic textfield = main_txt)
Here is the code I am using:
scrolling = function () {
var scrollHeight:Number = scroll_bar._height;
var contentHeight:Number = main_mc.main_txt._height;
var scroll_draggerHeight:Number = scroll_dragger._height;
var maskHeight:Number = main_mc.mask_mc._height;
var initPosition:Number = scroll_dragger._y=scroll_bar._y;
var initContentPos:Number = main_mc.main_txt._y;
var finalContentPos:Number = maskHeight-contentHeight+initContentPos;
var left:Number = scroll_bar._x;
var top:Number = scroll_bar._y;
var right:Number = scroll_bar._x;
var bottom:Number = scroll_bar._height-scroll_draggerHeight+scroll_bar._y;
var dy:Number = 0;
var speed:Number = 10;
var moveVal:Number = (contentHeight-maskHeight)/(scrollHeight-scroll_draggerHeight);
scroll_dragger.onPress = function() {
var currPos:Number = this._y;
startDrag(this, false, left, top, right, bottom);
this.onMouseMove = function() {
dy = Math.abs(initPosition-this._y);
main_mc.main_txt._y = Math.round(dy*-1*moveVal+initContentPos);
};
};
scroll_dragger.onMouseUp = function() {
stopDrag();
delete this.onMouseMove;
};
};
scrolling();
But, what it does is to scroll the textfield’s height instead of the text’s height. I suppose I need to use [COLOR=Red].textHeight[/COLOR] but I am a bit confused.
Any suggestions?
Thanks and Happy Holidays:)