# Scrollbar

**URL:** <https://forum.kirupa.com/t/scrollbar/328058>\
**Category:** Uncategorized\
**Created:** [April 16, 2012, 6:13am UTC](https://forum.kirupa.com/t/scrollbar/328058 "2012-04-16T06:13:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hutar](https://avatars.discourse-cdn.com/v4/letter/h/e47c2d/32.png) [@Hutar](https://forum.kirupa.com/u/Hutar)\
**Post date:** [April 16, 2012, 6:13am UTC](https://forum.kirupa.com/t/scrollbar/328058/1 "2012-04-16T06:13:25Z")

</div>

hello, i have one simple question. I did simple scrollbar for text which is loaded from external file. But, if the text in textfield is too short ( few words ) I dont want scrollbar to roll.  
_I would be grateful for any useful advice._

```auto
var loader:URLLoader = new URLLoader(new URLRequest("abcd.txt"));loader.addEventListener(Event.COMPLETE, completeHandler);

function completeHandler(event:Event):void{
    var loadedText:URLLoader = URLLoader(event.target);
    tSpeech.text = loadedText.data;
    }

tSpeech.multiline = true;
tSpeech.wordWrap = true; 

function upScrollText(evt:MouseEvent):void {
    trace(tSpeech.scrollV);
    tSpeech.scrollV -=1;
}
bScrollUp.addEventListener(MouseEvent.CLICK, upScrollText);

function downScrollText(evt:MouseEvent):void {
    trace(tSpeech.scrollV);
    tSpeech.scrollV +=1;
}
bScrollDown.addEventListener(MouseEvent.CLICK, downScrollText);

var bounds:Rectangle = new Rectangle(bScrollDrag.x, bScrollDrag.y,0,100);
var dragging:Boolean = false;  

function dragScroll(evt:MouseEvent):void{
    bScrollDrag.startDrag(false,bounds);
    dragging = true;
}
function dropScroll(evt:MouseEvent):void{
    bScrollDrag.stopDrag();
    dragging = false 
}
bScrollDrag.addEventListener(MouseEvent.MOUSE_DOWN, dragScroll);
stage.addEventListener(MouseEvent.MOUSE_UP, dropScroll);

function checkSlider(evt:Event):void {
    if(dragging) {
        //trace("scroll")
        tSpeech.scrollV = Math.round(bScrollDrag.y - bounds.y)*tSpeech.maxScrollV/100
        }
    }
stage.addEventListener(Event.ENTER_FRAME, checkSlider);

function speechScrolled(evt:Event):void{
    bScrollDrag.y = bounds.y + (tSpeech.scrollV*100/tSpeech.maxScrollV);
    }
tSpeech.addEventListener(Event.SCROLL, speechScrolled);

tSpeech.mouseWheelEnabled = true;

```
