Text Scroller in Flash
How to create simple & advanced Flash text scrollbars using actionscript
This tutorial explains how to create simple and advanced scrollers for textboxes in Flash using Actionscript. When there is only a limited area for text in Flash, it sometimes becomes a necessity to have scrollers.
You Are Here ::: Home >> Free Tutorials >> Flash Tutorials >> Text Scroller in FlashSimple Scroller for Flash Textboxes
- In Flash, textboxes are of 3 types namely - Static, Dynamic & Input. The size of Dynamic/Input text varies depending on the source file/user input and hence may require the use of scrollers.
- Create a Dynamic textbox with Multiline property selected using the Properties panel, name the variable and the instance as 'addr' and 'scrtxt' respectively.
- Create 2 buttons for Upward and Downward scrolling and write the following Actionscript code:
- Save your work and test the Movie (Ctrl + Enter). That's it you have learnt how to create simple scrollers for textboxes in Flash using Actionscript.
Upward Button
on(press)
{
scrtxt.scroll=scrtxt.scroll-1;
}
Downward Button
on(press)
{
scrtxt.scroll=scrtxt.scroll+1;
}
Simple Scrollbars
Advanced Scrollers for Flash Textboxes
- Functions can be used to control the button's scrolling action to create a more advanced type of text scrolling as explained below.
- Write two Actionscript functions, scrup and scrdown for scrolling upwards and downwards as shown below:
- Call these functions from the two Buttons using the following actionscript code:
- SetInterval is used to call a function after a certain period of time until it is cleared using the ClearInterval.
- Thus they help in creating scrollers that can scroll until the mouse is released as shown below.
- Save your work and test the Movie (Ctrl + Enter). That's it you have learnt how to create simple scrollers for textboxes in Flash using Actionscript.
function scrup()
{
scrtxt.scroll=scrtxt.scroll-1;
}
function scrdown()
{
scrtxt.scroll=scrtxt.scroll+1;
}
Upward Button
on(press)
{
upint=setInterval(scrup,100);
}
on(release)
{
clearInterval(upint);
}
Downward Button
on(press)
{
downint=setInterval(scrdown,100);
}
on(release)
{
clearInterval(downint);
}
Advanced Scrollbars using Mouse Press and Mouse Over Actions
Note: This is also applicable to Input text type. The rollOver and rollOut events of a Buttons can also be used to enable scrolling during mouseover events as shown above in the second swf.
Software Required
Compatible Versions of Flash for this Tutorial
Flash CS5 Professional | Flash CS4 Professional
Note: For uses of lower versions of Flash some visual interface images would differ.
Recommended Version: Adobe Flash CS5 Professional