# Need help with dynamic text

**URL:** <https://forum.kirupa.com/t/need-help-with-dynamic-text/278414>\
**Category:** flash\
**Created:** [December 29, 2008, 6:26pm UTC](https://forum.kirupa.com/t/need-help-with-dynamic-text/278414 "2008-12-29T18:26:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![slackulator](https://avatars.discourse-cdn.com/v4/letter/s/22d042/32.png) [@slackulator](https://forum.kirupa.com/u/slackulator)\
**Post date:** [December 29, 2008, 6:26pm UTC](https://forum.kirupa.com/t/need-help-with-dynamic-text/278414/1 "2008-12-29T18:26:57Z")

</div>

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:

```auto
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:)
