I have a problem getting a custom scroll bar working together with my scroll-buttons. I hope someone can help me further.
Here's the situation (I am using Actionscript 2):
I am pulling my text from an xml-file into a dynamic textbox.
Next to this textbox I have a up and a down button to scroll to the text. This works fine.
But, this way yoa are not able to see how many text is still to come, so I want to implement a custom scrollbar which will scroll with the text so you can see how much text is till to come. Also this scrollbar must be able to scroll the text, like the buttons do. And if you use the buttons to scroll, the scrolbar has to scroll along.
I can't seem to get the scrollbar working right. Either it scrolls, but the text is visible moving outside the dynamic textbox, and I cannot get thescrollbar and the up- and downbutton to work together.
The dynamic textfield is called 'content_tkst', the scrollbar is called scroller_mc.
The code for the buttons is as follows:
Two functions:
CODE
function scrup() {
content_tkst.scroll=content_tkst.scroll-1;
}
function scrdown() {
content_tkst.scroll=content_tkst.scroll+1;
}
And the code on the buttons:
Up-button:
CODE
on(press) { upint=setInterval(scrup,100);
}
on(release) { clearInterval(upint);
}
Down-button:
CODE
on(press) { downint=setInterval(scrdown,100);
}
on(release) { clearInterval(downint);
}
And here is the code I have sofar for the scrollbar:
CODE
var scrollUpper:Number = 227;
var scrollLower:Number = 517;
var textLower:Number = 196;
var textUpper = content_tkst.maxscroll;
var scrollRange:Number = scrollLower - scrollUpper;
var textRange = textLower - textUpper;
//trace (textRange);
function scroll() {
//upint=setInterval(scrup,100);
//setInterval(scrdown,100);
var moved:Number = scroller_mc._y - scrollUpper;
var pctMoved:Number = moved/scrollRange;
var textMove:Number = pctMoved*textRange;
content_tkst._y = textLower - textMove;
}
scroller_mc.onPress = function() {
this.startDrag (false,this._x,scrollUpper,this._x,scrollLower);
this.onMouseMove = scroll;
}
scroller_mc.onRelease = scroller_mc.onReleaseOutside = function() {
this.stopDrag();
this.onMouseMove = null;
}
Can someone please help me? I have been looking al over the internet, but everywhere there is a tut or a possible answer, the are talking about the components, and I don't want to use those.
Thnks in advance!