Discussion:
Creating Custom Scrollbar's For Dynamic Text Boxes
(too old to reply)
davidandrewheath
2006-02-17 12:19:20 UTC
Permalink
Hi there,

I've just implemented the tutorial on this page:

http://www.smartwebby.com/Flash/text_scrollers.asp

This example is great because it allows two buttons to be used to scroll a
dynamic text box. It doesn't use the technique which most of the other
tutorials of this nature use, which is to use a mask and move the text box up
and down. Basically it's the perfect example of what I need, apart from the
fact that it doesn't include instructions for how to implement the actual 'bar'
element of the scrollbar.

Is there a way to try and fit a scrolling feature into this tutorials' example
without it getting too over-complicated? My ActionScript is very poor, and so
any help I get with this is greatly appreciated.


Thanks,

Dave
kglad
2006-02-17 15:41:50 UTC
Permalink
create a dragbar track movieclip (with center reg point) and create a movieclip
dragbar (with center reg point) within the dragbar track. place the dragbar
track on the timeline that contains your textfield.

if you're using a vertical dragbar track, you can then use:

top=dragbarTrack._y-dragbarTrack._height/2-dragbarTrack.dragbar._height/2;
bottom=dragbarTrack._y+dragbarTrack._height/2-dragbarTrack.dragbar._height/2;

dragbarTrack.dragbar.onPress=function(){
this.startDrag(0,this._x,top,this._x,bottom);
dragI=setInterval(dragF,100);
}

dragbarTrack.dragbar.onRelease=dragbarTrack.dragbar.onReleaseOutside=function(){
this.stopDrag();
clearInterval(dragI);
}


function dragF(){
a=(txtbox.maxscroll-1)/(bottom-top);
b=1-a*top;
txtbox.scroll=a*dragbarTrack.dragbar._y+b;
}

p.s. you might want to change the dragbar's position when your buttons are
pressed.
davidandrewheath
2006-02-20 13:15:56 UTC
Permalink
Thanks for the reply.

Where exactly does the actions script you've posted go?

In the frame Actions, or in the button actions, or in the dragbartrack or in
the dragbar itself?

Also; you didn't specify what the instance names or movie clip names of each
of the elements was. I've called mine 'dragbartrack' and 'dragbar' currently
with no instance names. Is this right?

Thanks again.
kglad
2006-02-20 15:28:41 UTC
Permalink
you should attach that code to the timeline that contains your dragbarTrack.
and yes, use the instance names i used or change the names to match your
instance names.

and note that dragbarTrack is not the same as dragbartrack.
davidandrewheath
2006-02-22 11:47:21 UTC
Permalink
I'm having a bit of trouble implementing this.

At the moment my movie clip is structured as so (instance names in brackets):


MOVIE:

Dynamic Text Box (section1Text_txt) | Upward Button (upward) | Downward
Button (downward) | Dragbar Track (dragbarTrack) **

** Double clicking on this:

Dragbar (dragbar) | Your Action Script


I don't know whether this structure is wrong or not. Should the two
upward/downward buttons be in the dragbarTrack movie clip or not? Why aren't
they referenced in the ActionScript? Hopefully this will make it easier for you
to understand what I am doing.

Thanks for the help so far.
kglad
2006-02-22 15:57:34 UTC
Permalink
i thought you already had your buttons scripted. is that all you want are the buttons? if so, that's much easier.
Sammy12
2010-08-26 21:23:54 UTC
Permalink
I would like to say thanks to davidandrewheath for this great and easy solution for a custom scrollbar. As my project stands, I am unable to use Flash's built in UIScrollBar component, and this is a fantastic alternative. Best yet, it doesn't involve such a complicated set of actionscripts to work.. it just works! Even though it's 4 years after the original post, just wanted to express my thanks for your contribution

From http://www.developmentnow.com/g/69_2006_2_0_0_699427/Creating-Custom-Scrollbars-For-Dynamic-Text-Boxes.ht

Posted via DevelopmentNow.com Group
http://www.developmentnow.com/g/

Loading...