User Guide

1404 UIScrollBar Component
Description
Event; broadcast to all registered listeners when the mouse is clicked (released) over the scroll
bar. The
UIScrollBar.scrollPosition property and the scroll bars onscreen image are
updated before this event is broadcast.
The first usage example uses a dispatcher/listener event model, in which the script is placed on
a frame in the timeline that contains the component instance. A component instance
(
scrollBarInstance) dispatches an event (in this case, scroll) and the event is handled by
a function, also called a handler, on a listener object (
listenerObject) that you create. You
define a method with the same name as the event on the listener object; the method is called
when the event occurs. When the event occurs, it automatically passes an event object
(
eventObject) to the listener object method. The event object has properties that contain
information about the event. You can use these properties to write code that handles the
event. Finally, you call
addEventListener() (see EventDispatcher.addEventListener())
on the component instance that broadcasts the event to register the listener with the instance.
When the instance dispatches the event, the listener is called.
In addition to the normal properties of the event object (
type and target), the event object
for the
scroll event includes a third property named direction. The direction property
contains a string describing which way the scroll bar is oriented. The possible values for the
direction property are vertical (the default) and horizontal.
For more information about the
type and target event object properties, see “Event objects
on page 499.
The second usage example uses an
on() handler and must be attached directly to a
UIScrollBar component instance. The keyword
this, used inside an on() handler attached to
a component, refers to the component instance. For example, the following code, attached to
the UIScrollBar component instance
myUIScrollBarComponent, sends
“_level0.myUIScrollBarComponent” to the Output panel:
on (scroll) {
trace(this);
}