Text Scrollbars in Flash
Flash Tutorial to create Simple & Advanced Text Scrollers 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.
Software: Macromedia Flash MX or above
Recommended: Macromedia Flash MX Pro 2004
Simple Scrollers 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.
Absolutely FREE Web Templates
Check out these quality free web templates and download them without any registration or sign-up!
FREE Web Design Guide
From web design tips & ideas to HTML, CSS Styles, Fireworks & Dreamweaver you'll find all you need to know about effective web site design right here!
Quality Dreamweaver Templates
Professional quality dreamweaver templates in over 20 categories, starting at just $9.95! Instant download & easy customization