User Guide

UIScrollBar component 839
Example
The following code implements Usage 1. The code is attached to the UIScrollBar component
instance and sends a message to the Output panel when the user clicks the scroll bar. The
on()
handler must be attached directly to the UIScrollBar instance.
on(scroll){
trace("UIScrollBar component was clicked");
}
The following example implements Usage 2 and creates a listener object called myListener with
a
scroll event handler for the verticalScroll instance of the UIScrollBar component:
myListener = new Object();
myListener.scroll = function(eventObj){
// insert code to handle the "scroll" event
}
verticalScroll.addEventListener("scroll", myListener);
UIScrollBar.scrollPosition
Availability
Flash Player 6 (6.0 79.0).
Edition
Flash MX 2004.
Usage
scrollBarInstance.scrollPosition
Description
Property; gets or sets the current scroll position of the scrollable text field. The position of the
scroll box (thumb) also updates when a new
scrollPosition value is set. The value of
scrollPosition depends on whether the UIScrollBar instance is being used for vertical or
horizontal scrolling.
If the UIScrollBar instance is being used for vertical scrolling (the most common use), the value
of
scrollPosition is an integer with a range that begins with 0 and ends with a number that is
equal to the total number of lines in the text field divided by the number of lines that can be
displayed in the text field simultaneously. If
scrollPosition is set to a number greater than this
range, the text field simply scrolls to the end of the text.
To scroll the text to the first line, set
scrollPosition to 0.
To scroll the text to the end, set
scrollPosition to the number of lines of text in the text field
minus 1. You can determine the number of lines by retrieving the value of the
maxscroll
property of the text field.
If the UIScrollBar instance is being used for horizontal scrolling, the value of
scrollPosition is
an integer value ranging from 0 to the width of the text field, in pixels. You can determine the
width of the text field in pixels by getting the value of the
maxhscroll property of the text field.
The default value of
scrollPosition is 0.