"As you can see I've currently got the slider clip as a child of the
scrollBar clip - should I bring it out to the same level?"

On that matter, I would say, look carefully at your line of code that
follows: (scrollBar._height - scrollBar.slider._y)

If the slider is scrolled higher than _y = 0 or that the slider goes lower
than scrollBar._height your slider will influence the scrollBar._height
value. This can be quite dangerous for weird acting script, but if your sure
your slider won't ever influence it's containers height, your Ok.
What I might suggest you would be to use the scrollBar.scrollTrack._height
that might be existent or not in your scrollBar movieclip. 

Now for your script, I don't usually go that way of doing it so here is how
I'd probably do it myself:

var scrollRatio = scrollBar.slider._y / scrollBar.scrollTrack._height;
currentChild._y = - scrollRatio * currentChild._height;

I'm not 100% sure but I think this should work. Notice the negative value
for the currentChild._y. 

Fredz./

 




-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Kent
Humphrey
Sent: October 29, 2005 12:28 PM
To: Flashcoders mailing list
Subject: [Flashcoders] scrolling problem

Can someone help me with this code?

I'm trying to figure out how to scroll an MC up and down based on the
position 
of a scrollbar.

What am I doing wrong with this code?
I'm finding the ratio between how tall the content is (currentChild) and how

tall the scrollbar is:

scrollRatio = currentChild._height/scrollBar._height;

Then changing the position of the content depending on where the 
scrollBar.slider is:

currentChild._y = (scrollBar._height - scrollBar.slider._y)*scrollRatio;

The result of this is the content is not visible until the scrollbar slider
is 
most of the way down it's length, and then the content doesn't scroll far
enough.

As you can see I've currently got the slider clip as a child of the
scrollBar 
clip - should I bring it out to the same level?

Anyone got any ideas?

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to