ActionScript.org Flash, Flex and ActionScript Resources - http://www.actionscript.org/resources
Dynamic text with scrollbar
http://www.actionscript.org/resources/articles/151/1/Dynamic-text-with-scrollbar/Page1.html
Greg Meyer
This user is yet to take control of their account and provide a biography. If you are the author of this article, please contact us via support AT actionscript DOT org. 
By Greg Meyer
Published on September 9, 2005
 
Tutorial details:
Written by: Greg Meyer [email:greg@hopepres.com]
Difficulty Level: Advanced
Requirements: Flash 4
Download FLA

Page 1 of 2
Tutorial details:
Written by: Greg Meyer [email:greg@hopepres.com]
Difficulty Level: Advanced
Requirements: Flash 4
Download FLA

NB: Tutorial upated May 23rd 2001

1) Let start.



Create 2 lyers "actions" and "Lyer 1"

Add actionscript for lyer "actions" on frame 1 :
[as]
ms = textbox.Message.maxscroll;
if (ms>1) {
if (dragpress<1) {
scale = 138/ms;
_root.textbox.scrollbar.scrollbox._yscale = 200/textbox.Message.maxscroll;
_root.textbox.scrollbar.scrollbox._y = -68+((textbox.Message.scroll-1)*scale);
if (textbox.scrollbar._visible == false) {
_root.textbox.scrollbar._visible = true;
}
} else if (textbox.scrollbar.scrollbox._y<-66 and move<0) {
move = 0;
textbox.scrollbar.scrollbox._y = -68;
} else if (textbox.scrollbar.scrollbox._y+textbox.scrollbar.scrollbox._height>69 and move>0) {
move = 0;
} else {
textbox.scrollbar.scrollbox._y = textbox.scrollbar.scrollbox._y+(move*scale);
textbox.Message.scroll = ((textbox.scrollbar.scrollbox._y+68)/scale)+1.2;
}
} else {
if (textbox.scrollbar._visible == true) {
textbox.scrollbar._visible = false;
}
}
[/as]
Add actionscript for lyer "actions" on frame 2:
[as]
gotoAndPlay (1);
[/as]
Create MC (emailmovie) for lyer "Lyer 1" and in INSTANS window name is a "textbox"



Edit MC (emailmovie)



Lyer 2 has an actionscript on frame 1
[as]
loadVariables ("message.txt", "_root.textbox");
stop ();
[/as]
Lyer 1 has a text field on frame 1
Lyer 3 has a MC scrollbar on frame 1 and in INSTANS window name is a "scrollbox"


Page 2 of 2
Lyer 4 frame 1 actionscript :
[as]
scrollboxtop = _root.scrollbar.scrollbox._y;
scrollboxbottom = _root.scrollbar.scrollbox._y + (_root.scrollbar.scrollbox._height) ;
if (textbox.Message.scroll=1) {
if (scrollboxmove >0) {
scrollboxmove = 0;
}
_root.scrollbar.scrollbox._y = -68;
} else if (scrollboxbottom - scrollboxmove > 70) {
if (scrollboxmove <0) {
scrollboxmove = 0;
}
_root.scrollbar.scrollbox._y = 70 - _root.scrollbar.scrollbox._height;
scrollboxmove = 0;
} else {
_root.textbox.Message.scroll = _root.textbox.Message.scroll + scrollboxmove;
}
[/as]
Lyer 4 frame 2 actionscript :
[as]
stop ();
[/as]
Lyer 1 has a MC "scrollbox" and in INSTANS window name is a "scrollbox". And inside of MC we have "scrollboxdrag" button.



Lyer 5 has a 2 arrowbuttons:

Action for Top button
[as]
on (press) {
if (_root.textbox.Message.scroll>1) {
_level0.dragpress = 1;
_level0.move = -1;
}
}
on (release) {
_level0.dragpress = 0;
_level0.move = 0;
}
[/as]
Action for Bottom button
[as]
on (press) {
if (_root.textbox.Message.scroll<_root.textbox.Message.maxscroll) {
_level0.dragpress = 1;
_level0.move = 1;
}
}
on (release) {
_level0.dragpress = 0;
_level0.move = 0;
}
[/as]