20070417
scroll_silver.swi is a vertical scroll bar.

Properties
==========
WindowSize:	Size of the display window. Units can be in pixels or lines.
DocumentSize:	Size of the document. Units must match WindowSize units.
Step:		Number of units to step for each up / down button press.
Reverse:	Indicates if position is to increment in same direction as slider. 
EventVar:	The name of the variable that the final value is written. 
EventFunction:	The name of the event function in the parent object. 
Direction:	Vertical or Horizontal scrollbar.

Methods
=======
init(WindowSize,DocumentSize,Step)
Sets the WindowSize, DocumentSize and Step size to new values. 

setstart(percent)
Sets the position of the scroll bar slider. Expressed as a percent. 0 = top, 100 = bottom.

version()
returns the version date in the format "YYYYMMDD"

Event Function
==============
The above components call a user defined event function when changing their state.
The function takes two parameters: 
1. The name (or group name) of the object.
2. The new value associated with the object. This will be a position between 0 and the defined DocumentSize.

The event function is assumed to exist at the parent level of the object.
A sample event function is shown below:

function EventListener(group,value)
{
    // send the object name and new value to debug panel.
    trace(group add ":" add value);
}

As the function is passed the name of the component that activated it, a common function can be used to handle
events from multiple components.

Examples
========
1. Scroll a picture inside a masking sprite. 
See Samples/Components/scroll_example.swi

The image size is 1885wx2853w
Window size is 220x220

For the vertical scrollbar (scrollbar), use the following
WindowSize: 220
DocumentSize: 2853
Step: 28 (2853/100)
ReverseOutput: true
EventVar = _parent.pic.image._Y

For the horizontal scrollbar (scrollbar_h), use the following
WindowSize:220
DocumentSize:1885
Step: 19 (1885/100)
ReverseOutput: true
EventVar = _parent.pic.image._X

Position the image so that top left hand corner is aligned with top left hand corner of the mask.

2. Scroll text.
See Samples/Components/scroll_text_example.swi
EXAMPLE of scrolling text with scrollbar.
________________________________

Set the scrollbar properties as follows:
ReverseOutput: False
EventVar: 
EventFunction: SetScroll
WindowSize, DocumentSize and Step are ignored as these are set by the 
Resize() function. (See below).

___________________________________________________________
Create a multi line dynamic text object called t1 at the same depth as the 
scrollbar. Within t1 create the following functions:

function Resize()
{
    G_lines=this._text.bottomScroll - this.scroll+1;
    G_range = this.maxscroll+G_lines;    // use if not device font.
 
    _parent.scrollbar.init(G_lines,G_range,1);    
}

onSelfEvent (load)
{
    Resize();
}

The resize function calculates the range and window size and then 
resizes the scroll bar slider appropriately.

__________________________________________________________________
Create a function in the common parent object as shown below to do the scrolling:
function SetScroll(name,p)
{
    t1.scroll = int(p + 1.5);
}

This is the function referenced by the EventFunction property.
Note: the function must exist in the scrollbars parent object.
Note: the scrollbar must be below the t1 object in the outline tree. This is to ensure that the 
scrollbar is initialised before the t1.onSelfEvent (load) function calls scrollbar.init().
