|I l @ ve RuBoard|
If you bring up the Properties panel and select a dynamic text field, you will see that you can name the text field in addition to assigning it to a variable. In Figure 14.2, the dynamic text field is named scrollText.
Figure 14.2. You must name your text fields to control them with ActionScript. This one is named scrollText.
After you name a text field, you can refer to it in your ActionScript code and get and set its properties. But before you do that, you need to change the text field to allow it to scroll.
If you select a field, you can grab and drag the white box at the bottom-right corner of the field to change its size . However, the field always remains big enough so that all the text is visible. You cannot shrink it so that some of the text is not visible.
Instead of dragging this white box, you need to first change the text field so that it has a black box at the bottom right. To do this, hold down the Shift key and click on the white box; it should change to a solid black box. Now you can drag it so that the text field is smaller than the text it holds.
Now that you have changed the text field to make it scrollable, several properties of a text field relate to scrolling.
The scroll property tells you what line is the first one visible on the screen. If scroll is 1, the first line is visible. If scroll is 2, the first line is hidden, and the second line of the text is the first line visible.
The maxscroll property tells you what the largest possible value for scroll is, given the size of the field and the text in it. So if the field is actually 20 lines long, but only 10 lines are visible at a time, maxscroll will be 11. Why? Because when scroll is equal to 11, lines 11 through 20 are in the visible area, line 20 being the last line. You can't scroll to line 12, because that would attempt to make lines 12 through 21 visible, and there is no line 21.
The scroll and bottomScroll properties of the field tell you precisely which line is at the top and which is at the bottom. So if you subtract 1 from the other and add 1, you get the total number of visible lines in the field.
To make a scrolling field move up and down, all we need to do is increase or decrease scroll . We don't even need to check for this value going below 1 or above the maxscroll because Flash just does not allow it. For instance, if you set the scroll property of a field to 0, Flash simply adjusts it to 1.
|I l @ ve RuBoard|