Groups | Blog | Home
all groups > flash actionscript > january 2006 >

flash actionscript : Please HELP!!!


Motion Maker
1/5/2006 8:11:26 PM
Answer is in the Flash documentation for the TextField scroll property as a
button example:

http://livedocs.macromedia.com/flash/8/main/00002774.html


scrollUp_btn.onRelease = function() {
my_txt.scroll--;
scroll_txt.text = my_txt.scroll+" of "+my_txt.maxscroll;
};
scrollDown_btn.onRelease = function() {
my_txt.scroll++;
scroll_txt.text = my_txt.scroll+" of "+my_txt.maxscroll;
};


--
Lon Hosford
www.lonhosford.com
May many happy bits flow your way!
[quoted text, click to view]
I really need to know how to do this...PLEASE, any help would be greatly
appreciated

I have been working on the code to scroll a dynamic text field. I've gotten
buttons to scroll the text when clicked and I've gotten a scroll bar to
scroll
text when dragged. What I need to do now is get the scroll bar to scroll up
or
down when the up/down buttons are pressed.

Do any of you know how to do this?

Thanks,

Kyle

This is the code that I have so far:

//-----------------------<Scrolling>-----------------------\\

this.scrollDown.onPress = function () {
scrollDirection = "down";
scrollText();
}
this.scrollDown.onRelease = function(){
delete _root.onEnterFrame;
}
this.scrollDown.onReleaseOutside = function(){
delete _root.onEnterFrame;
}
this.scrollUp.onPress = function () {
scrollDirection = "up";
scrollText();
}
this.scrollUp.onRelease = function(){
delete _root.onEnterFrame;
}
this.scrollUp.onReleaseOutside = function(){
delete _root.onEnterFrame;
}
function scrollText(){
_root.onEnterFrame = function(){
if(scrollDirection == "up"){
loadedInfo.scroll -= 1;
} else if (scrollDirection == "down"){
loadedInfo.scroll += 1;
}
}
}
Scroller.onPress = function(){
interval = setInterval(update, 1);
this.startDrag(false, 926, 118, 926, 461);
}
Scroller.onRelease = function(){
clearInterval(interval);
this.stopDrag();
}
Scroller.onReleaseOutside = function(){
clearInterval(interval);
this.stopDrag();
}
function update(): Void {
loadedInfo.scroll =
Math.floor((Scroller._y-110)/((-110+461)/loadedInfo.maxscroll));
}
//-----------------------<Scrolling>-----------------------\\

kypsul
1/5/2006 11:48:56 PM
I really need to know how to do this...PLEASE, any help would be greatly
appreciated

I have been working on the code to scroll a dynamic text field. I've gotten
buttons to scroll the text when clicked and I've gotten a scroll bar to scroll
text when dragged. What I need to do now is get the scroll bar to scroll up or
down when the up/down buttons are pressed.

Do any of you know how to do this?

Thanks,

Kyle

This is the code that I have so far:

//-----------------------<Scrolling>-----------------------\\

this.scrollDown.onPress = function () {
scrollDirection = "down";
scrollText();
}
this.scrollDown.onRelease = function(){
delete _root.onEnterFrame;
}
this.scrollDown.onReleaseOutside = function(){
delete _root.onEnterFrame;
}
this.scrollUp.onPress = function () {
scrollDirection = "up";
scrollText();
}
this.scrollUp.onRelease = function(){
delete _root.onEnterFrame;
}
this.scrollUp.onReleaseOutside = function(){
delete _root.onEnterFrame;
}
function scrollText(){
_root.onEnterFrame = function(){
if(scrollDirection == "up"){
loadedInfo.scroll -= 1;
} else if (scrollDirection == "down"){
loadedInfo.scroll += 1;
}
}
}
Scroller.onPress = function(){
interval = setInterval(update, 1);
this.startDrag(false, 926, 118, 926, 461);
}
Scroller.onRelease = function(){
clearInterval(interval);
this.stopDrag();
}
Scroller.onReleaseOutside = function(){
clearInterval(interval);
this.stopDrag();
}
function update(): Void {
loadedInfo.scroll =
Math.floor((Scroller._y-110)/((-110+461)/loadedInfo.maxscroll));
}
//-----------------------<Scrolling>-----------------------\\
Motion Maker
1/6/2006 11:14:26 AM
If you are using the Flash Component ScrollBar, it will do that
automatically.

If you are writing a custom scroll bar then you may need to write a monitor
function with a timer that will monitor the scroll property of the
TextField. The monitor function basically is a timer that will adjust its
thumb position based on a percentage of the scroll of maxscroll.


--
Lon Hosford
www.lonhosford.com
May many happy bits flow your way!
[quoted text, click to view]
Thank you for the help, but I think that just scrolls the text. I can
already
scroll the text with a button. My problem is I want the buttons to move the
scroll bar not just the text. So when you press the down button the text and
the scroll bar move together.

kypsul
1/6/2006 2:28:48 PM
Thank you for the help, but I think that just scrolls the text. I can already
scroll the text with a button. My problem is I want the buttons to move the
scroll bar not just the text. So when you press the down button the text and
the scroll bar move together.
Motion Maker
1/6/2006 3:50:48 PM
I remember searching for one a while back and came up short.

I suggest you start a new thread with a better subject line and you might
get more feedback.

For example "Need help coding custom texfield scroll bar update monitoring"

In general you use setInterval and fire off a function that checks the
TextField scroll and maxscroll properties and then the function updates the
thumb position based on the percentage of the scroll line to the maxscroll.

A lot of what the function will do depends on the object metrics of the
scroll bar. Assuming it is your custom scroll bar then you will have a
handle on those items.

This may give you an idea.
Create a new movie

Create a dynamic (or input) text field, multiline, _typewriter, 12 point,
left justified, w:110, h:120, show border. Name it my_txt

Add following code on frame.

my_txt.text = ""
for (lineI = 1; lineI <= 25 ; lineI++)
{
my_txt.text += "Line " + lineI + newline

}


var myMonitor:Object = new Object()
myMonitor.getTextFieldData = function()
{
trace ("myMonitor.getTextFieldData")
trace ("\tmy_txt.scroll = " + my_txt.scroll)
trace ("\tmy_txt.maxscroll = " + my_txt.maxscroll)
trace ("\tscroll percent = " + (my_txt.scroll - 1) / (my_txt.maxscroll - 1)
* 100)

}
myMonitor.interval = setInterval(myMonitor, "getTextFieldData", 500);


Control->Test movie. Click in the textfield and move the up and down arrow
key on your keyboard and watch the output window.

You would use the data to thus move a thumb in the scroll bar.

There are many programming approaches to the problem, this is one direction.

--
Lon Hosford
www.lonhosford.com
May many happy bits flow your way!
[quoted text, click to view]
yeah I am using a custom scroll bar. Do you know of any place that might
have
an example of writing a function using the timer. Or might you know of how
to
write such a function. I know how to write a function but I am new to
ActionScript so any coding clues would help.

Thanks,

Kyle

kypsul
1/6/2006 4:42:53 PM
yeah I am using a custom scroll bar. Do you know of any place that might have
an example of writing a function using the timer. Or might you know of how to
write such a function. I know how to write a function but I am new to
ActionScript so any coding clues would help.

Thanks,

Kyle
kypsul
1/9/2006 2:28:14 PM
Thank you for your help on this. I will try what you suggested. I've also
looked all over and it is a hard thing to find. I found some scrollers that
were built by other programmers, but trying to figure out their code was near
impossible. Anyway what you wrote is pretty straight forward and I will try it
out. Thanks again for your help.
AddThis Social Bookmark Button