Joshua Maerten
Joshua Maerten

Reputation: 183

AutoScrolling Slow down

I found this, but got no idea how to slow it down:

var myTextLoader:URLLoader = new URLLoader(); 
myTextLoader.addEventListener (Event.COMPLETE,onLoaded); 
function onLoaded (e:Event):void 
{ 
    tekstbx.text = e.target.data; 
    tekstbx.addEventListener (Event.ENTER_FRAME,efh); 
} 

myTextLoader.load (new URLRequest("tekst.txt")); 
function efh (event:Event):void 
{ 
    event.currentTarget.scrollV += 1; 
    if (event.currentTarget.scrollV>=event.currentTarget.maxScrollV) 
    { 
        event.currentTarget.scrollV-=1; 
        event.currentTarget.removeEventListener (Event.ENTER_FRAME,efh); 
        event.currentTarget.addEventListener (Event.ENTER_FRAME,efV); 
    } 

} 
function efV (event:Event):void 
{ 
    event.currentTarget.scrollV-=1; 
    if (event.currentTarget.scrollV<=1) 
    { 
        event.currentTarget.scrollV-=1; 
        event.currentTarget.removeEventListener (Event.ENTER_FRAME,efV); 
        event.currentTarget.addEventListener (Event.ENTER_FRAME,efh); 
    } 

} 

Upvotes: 0

Views: 327

Answers (2)

back2dos
back2dos

Reputation: 15623

Since TextField::scrollV is an int, you cannot simply slow it down. You could use @Kodiak's solution to scroll less frequently, which will result in a movement, that is slower, but also less smooth.

Alternatively, you could have a look at DisplayObject::scrollRect. This will allow you scrolling on based on pixels, rather than text lines.

Upvotes: 0

Kodiak
Kodiak

Reputation: 5978

You could either replace the listener on ENTER_FRAME with a Timer: you will then slow the scroll by using a larger delay on your timer. Or you can change all the "1"s by a smaller number (you should then use a constant to be sure the value is the same everywhere when you change it).

Upvotes: 1

Related Questions