ScrollBarInit Actionscript

Table of contents | Previous document | Download ScrollBarInit.as | SWF!T Homepage

RCSfile: ScrollBarInit.as,v  Revision: 1.4  Date: 2003/01/29 16:40:19  

Copyright 2003 Orgdot AS. All Rights Reserved. http://dev.swfit.com
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.


This script prepares a scrollbar consisting of one draggable movie clip (named "button" and a movie clip that serves as bounding box (named "background").
author      Olaf Havnes
version     Revision: 1.4  Date: 2003/01/29 16:40:19  
since       SWFIT1.0


Controls the bounce

DEFAULT_DELAY = 2.5;

Controls the snap

DEFAULT_SNAP = 10;
snp = snap ne "" ? snap : DEFAULT_SNAP;

Controls the leverage

DEFAULT_LEVERAGE = 0.02;
lvrg = leverage ne "" ? leverage : DEFAULT_LEVERAGE;

Controls the scroll button leverage

DEFAULT_SCROLL_SPEED = 4;
scroll_spd = scroll_speed ne "" ? scroll_speed : DEFAULT_SCROLL_SPEED;

Name of the full scrollbar must be "name of scrollabe object" + either "_scroll" or "_scrolltxt"

NAME_ENDING = "_scroll";
TEXT_ENDING = "_scrolltxt";

Do we scroll a text (html) field ?

txt_scroll = TEXT_ENDING eq substring (_name, 1 + length(_name) - length (TEXT_ENDING), length (TEXT_ENDING));

scroll_object = txt_scroll ?

   "../:" add substring (_name, 1, length(_name) - length (TEXT_ENDING)) :
   "../"  add substring (_name, 1, length(_name) - length (NAME_ENDING));

store non-int value for text scrolling

scroll_nmb = "";

In which direction do we move the scroll button ?

HORIZONTAL = "horizontal";
scroll_horz = scroll_direction eq HORIZONTAL;

Do we round off to closest pixel ?

ON_FLAG = "on";
pxl = pixel eq ON_FLAG;


Do we hide the scroller if there is nothing to scroll ?

hde_scroll = hide_scroll eq ON_FLAG;

Measure the bounding box for the scroll button

x0 = button._x;
y0 = button._y;

pos_x = x0;
pos_y = y0;

min_x = background._x;
min_y = background._y;

max_x = min_x + background._width  - button._width ;
max_y = min_y + background._height - button._height;


Get the starting point for the scrollable object

if (!txt_scroll)
{
   scroll_x0 = getProperty (scroll_object, _x);
   scroll_y0 = getProperty (scroll_object, _y);
}