External Source with Scrollbars
| Category | : Flash | Views | : 17016 | ||
| Version | : 8 | Rating | : | ||
| Type | : Text | Source File | : external-source-with-scrollbars.zip | ||
| Result | : See the result | ||||
Below you can see the result for this tutorial, the text is written in Loren Ipsum just as a place holder for the text.

First create the textbox that you intent to scroll and use these properties:

1. Instance name
2. Make the text selectable
3. Allow html tags, that's how we are going to display an image
4. Show a border around the text box
Now drag an instance of the UIScrollBar component to the stage, just go to Window à Components (Ctrl + F7) and drag it from there.
After that, drag the instance to the text box and the ScrollBar will automatically create a link to it.
If you select the ScrollBar and click on the parameters tab you will see two fields; the first is the instance name of the textbox that the scroll bar is linked to and the second is whether the scroll bar is horizontal or not.
For this tutorial we are going to use it in the vertical position, so set the last parameter to false.
Create a new .txt file and write whatever you want using as many lines as you can so you can use the scroll bar later and in the middle of your text paste this:
//this will display the image named "flash.jpg" in the texbox
In the beginning of the text paste this:
content=(your text)
"content" is how we are going to call this text in the actionscript later. It will work as a variable name.Save the file as "content.txt" and get an image named "flash.jpg" in the same folder.
Now go to the actions for the first frame and paste:
//object to load variable from text files
textFile = new LoadVars()
//load our text file
textFile.load("content.txt");
//when finished the loading
textFile.onLoad = function ()
{
//the html text of the textbox is equal to variable "content" inside the file we loaded
_root.scrollText.htmlText = this.content
}
That's all; if you want you can add another scrollbar to the textbox just set the "horizontal" parameter of the new instance to true and drag it to the textbox.
Code Explanation
textFile = new LoadVars()
Create a new LoadVars object.
textFile.load("content.txt");
Load the text file with the text with the LoadVars object.
textFile.onLoad = function ()
{
_root.scrollText.htmlText = this.content
}
Set the text of the textbox to the variable "content" inside the textfile we loaded in the textFile object.