TextField.bottomScroll Property

ActionScript for Flash MX: The Definitive Guide, 2nd Edition
By Colin Moock
Chapter 18.  ActionScript Language Reference
TextField.bottomScroll Property Flash 6

the 1-relative index of the text field's lowest visible line read-only
theField.bottomScroll

Description

The integer bottomScrollproperty represents the 1-relative line number of the bottommost line currently displayed in a text field.

When the text in a text field spans more lines than can be accommodated by the physical viewable region of the field, extra lines of text are hidden but are still part of the text field. The top line is number 1, and line numbers increase for every line in the text field, including those that exceed the viewable boundaries of the field. See Figure 18-6 under TextField.scroll, which shows a sample text field's line index values.

When a text field contains more lines than it can display at once, we can determine the range of lines displayed by using the scroll and bottomScroll properties. The maxScroll property returns the index of the top visible line when the field is scrolled as far as possible, but it doesn't tell us the total number of lines in the field. Though there is no separate property for this, we can determine the index of the last line by temporarily setting scroll to maxScroll and checking bottomScroll, as follows:

theField_txt.oldScroll = theField_txt.scroll; theField_txt.scroll = theField_txt.maxscroll; trace("Number of lines in text field is " + theField_txt.bottomScroll); theField_txt.scroll = theField_txt.oldScroll;

Reader Exercise: Create a custom property, maxBottomScroll, that stores the number of lines in a field. Write a getMaxBottomScroll( ) function to retrieve it.

Example

We can calculate the number of lines currently displayed in a text field (sometimes referred to as the field's page size) by subtracting scroll - 1 from bottomScroll. The following code adds a getPageSize( ) method to all TextField objects; when invoked on a TextField instance, the method returns the number of viewable lines in that field:

TextField.prototype.getPageSize = function () {   var pageSize = this.bottomScroll - (this.scroll - 1);   trace("Page size is " + pageSize);   return pageSize; }

The page size of a text field can be used to scale a scroll handle proportionately in a corresponding scroll bar. Note that the number of displayable lines in a field can vary, depending on the font sizes of the currently displayed text.

See Also

TextField.maxscroll, TextField.scroll; the FScrollBar component in Appendix E



    ActionScript for Flash MX. The Definitive Guide
    ActionScript for Flash MX: The Definitive Guide, Second Edition
    ISBN: 059600396X
    EAN: 2147483647
    Year: 2002
    Pages: 780
    Authors: Colin Moock

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net