home *** CD-ROM | disk | FTP | other *** search
- class com.rightactionscript.fcb.components.ScrollBar extends com.rightactionscript.fcb.components.UIBasicComponent
- {
- var mcBoundingBox;
- var mcHolder;
- var mcUpArrowTemp;
- var mcDownArrowTemp;
- var mcTrackTemp;
- var mcThumbTemp;
- var interval;
- var onRelease;
- var onRollOut;
- var dispatchInterval;
- var scrollInterval;
- var mcThumb;
- var _nPage;
- var _nMin;
- var _nMax;
- var _nDragOffset;
- var _nPrevScrollPosition;
- var dispatchEvent;
- var _tTarget;
- var addEventListener;
- var _sSnapTo;
- var _oListener;
- var target;
- var parent;
- var _nSize;
- var _bHorizontal;
- var __height;
- function ScrollBar()
- {
- super();
- }
- function createChildren()
- {
- this.mcBoundingBox._visible = false;
- this.mcBoundingBox._width = 0;
- this.mcBoundingBox._height = 0;
- this.createEmptyMovieClip("mcHolder",this.getNextHighestDepth());
- this.mcHolder.attachMovie("ScrollBarUpArrow","mcUpArrow",this.mcHolder.getNextHighestDepth());
- this.mcHolder.attachMovie("ScrollBarDownArrow","mcDownArrow",this.mcHolder.getNextHighestDepth());
- this.mcHolder.attachMovie("ScrollBarTrack","mcTrack",this.mcHolder.getNextHighestDepth());
- this.mcHolder.attachMovie("ScrollThumb","mcThumb",this.mcHolder.getNextHighestDepth());
- this.mcUpArrowTemp._visible = false;
- this.mcDownArrowTemp._visible = false;
- this.mcTrackTemp._visible = false;
- this.mcThumbTemp._visible = false;
- this.mcHolder.mcUpArrow.onRollOver = function()
- {
- this.gotoAndStop("over");
- };
- this.mcHolder.mcUpArrow.onRollOut = function()
- {
- this.gotoAndStop("up");
- };
- this.mcHolder.mcUpArrow.onPress = function()
- {
- this.gotoAndStop("down");
- this.interval = setInterval(this._parent._parent,"scrollThumb",50,-1,false);
- };
- this.mcHolder.mcUpArrow.onRelease = function()
- {
- this.gotoAndStop("over");
- clearInterval(this.interval);
- };
- this.mcHolder.mcUpArrow.onReleaseOutside = function()
- {
- this.onRelease();
- this.onRollOut();
- };
- this.mcHolder.mcDownArrow.onRollOver = function()
- {
- this.gotoAndStop("over");
- };
- this.mcHolder.mcDownArrow.onRollOut = function()
- {
- this.gotoAndStop("up");
- };
- this.mcHolder.mcDownArrow.onPress = function()
- {
- this.gotoAndStop("down");
- this.interval = setInterval(this._parent._parent,"scrollThumb",50,1,false);
- };
- this.mcHolder.mcDownArrow.onRelease = function()
- {
- this.gotoAndStop("over");
- clearInterval(this.interval);
- };
- this.mcHolder.mcDownArrow.onReleaseOutside = function()
- {
- this.onRelease();
- this.onRollOut();
- };
- this.mcHolder.mcThumb.onRollOver = function()
- {
- for(var _loc2_ in this)
- {
- this[_loc2_].gotoAndStop("over");
- }
- };
- this.mcHolder.mcThumb.onRollOut = function()
- {
- for(var _loc2_ in this)
- {
- this[_loc2_].gotoAndStop("up");
- }
- };
- this.mcHolder.mcThumb.onPress = function()
- {
- for(var _loc2_ in this)
- {
- this[_loc2_].gotoAndStop("down");
- }
- this._parent._parent._nDragOffset = - this._ymouse;
- this.dispatchInterval = setInterval(this._parent._parent,"dispatchScrollEvent",50);
- this.scrollInterval = setInterval(this._parent._parent,"scrollThumb",50,null,true);
- };
- this.mcHolder.mcThumb.onRelease = this.mcThumb.onReleaseOutside = function()
- {
- for(var _loc2_ in this)
- {
- this[_loc2_].gotoAndStop("over");
- }
- clearInterval(this.scrollInterval);
- clearInterval(this.dispatchInterval);
- };
- this.mcHolder.mcThumb.onReleaseOutside = function()
- {
- this.onRelease();
- this.onRollOut();
- };
- this.mcHolder.mcTrack.onPress = function()
- {
- if(this._parent._parent._parent._bHorizontal)
- {
- var _loc4_ = this._parent._xmouse;
- var _loc3_ = this._parent.mcThumb._x;
- }
- else
- {
- _loc4_ = this._parent._ymouse;
- _loc3_ = this._parent.mcThumb._y;
- }
- var _loc2_ = this._parent._parent._nPage * 100 / (this._parent._parent._nMax - this._parent._parent._nMin);
- if(_loc4_ < _loc3_)
- {
- _loc2_ = - _loc2_;
- }
- this._parent._parent.scrollThumb(_loc2_);
- };
- }
- function setScrollProperties(nPage, nMin, nMax)
- {
- this._nPage = nPage;
- this._nMin = Math.max(nMin,0);
- this._nMax = Math.max(nMax,0);
- this.resizeThumb();
- }
- function resizeThumb()
- {
- this.mcHolder.mcThumb.height = Math.abs(this._nPage / (this._nMax - this._nMin) * this.mcHolder.mcTrack._height);
- this.mcHolder.mcThumb._y = this.mcHolder.mcUpArrow._height;
- if(this.mcHolder.mcThumb.height > this.mcHolder.mcTrack._height)
- {
- this.mcHolder.mcThumb._visible = false;
- }
- else
- {
- this.mcHolder.mcThumb._visible = true;
- }
- }
- function scrollThumb(nAmount, bDrag)
- {
- if(bDrag)
- {
- this.mcHolder.mcThumb._y = this.mcHolder._ymouse + this._nDragOffset;
- }
- else
- {
- this.mcHolder.mcThumb._y += nAmount;
- }
- if(this.mcHolder.mcThumb._y < this.mcHolder.mcUpArrow._height)
- {
- this.mcHolder.mcThumb._y = this.mcHolder.mcUpArrow._height;
- }
- else if(this.mcHolder.mcThumb._y > this.mcHolder.mcDownArrow._y - this.mcHolder.mcThumb._height)
- {
- this.mcHolder.mcThumb._y = this.mcHolder.mcDownArrow._y - this.mcHolder.mcThumb._height;
- }
- this.dispatchScrollEvent();
- }
- function dispatchScrollEvent()
- {
- if(this.mcHolder.mcThumb._y != this._nPrevScrollPosition)
- {
- this._nPrevScrollPosition = this.mcHolder.mcThumb._y;
- this.dispatchEvent({type:"scroll",target:this});
- }
- }
- function set scrollTarget(tTarget)
- {
- this._tTarget = typeof tTarget != "string" ? tTarget : this._parent[tTarget];
- if(this._tTarget == "" || this._tTarget == null)
- {
- this._tTarget = undefined;
- return;
- }
- if(this.addEventListener != undefined)
- {
- this.addTargetListener();
- }
- this.addToQueue({object:this,method:this.addTargetListener});
- if(this._sSnapTo != undefined && this._sSnapTo != "none")
- {
- this.addToQueue({object:this,method:this.snapToTextField});
- }
- }
- function get scrollTarget()
- {
- return this._tTarget;
- }
- function set snapTo(sSnapTo)
- {
- this._sSnapTo = sSnapTo;
- if(this._tTarget != undefined)
- {
- if(this.addEventListener != undefined)
- {
- this.snapToTextField();
- }
- else
- {
- this.addToQueue({object:this,method:this.snapToTextField});
- }
- }
- }
- function snapToTextField()
- {
- if(this._sSnapTo == "right")
- {
- this._x = this._tTarget._x + this._tTarget._width - this._width;
- this._y = this._tTarget._y;
- this._tTarget._width -= this._width;
- this.height = this._tTarget._height;
- this.setScrollPropertiesToTarget();
- }
- }
- function addTargetListener()
- {
- this._oListener = new Object();
- this._oListener.target = this._tTarget;
- this._oListener.parent = this;
- this._oListener.scroll = function(oEvent)
- {
- this.target.scroll = this.target.maxscroll * (this.parent.scrollPosition / Math.abs(this.parent._nMax - this.parent._nMin));
- };
- this.addEventListener("scroll",this._oListener);
- this.setScrollPropertiesToTarget();
- }
- function setScrollPropertiesToTarget()
- {
- var _loc2_ = this._tTarget.textHeight;
- var _loc3_ = 0.9 * this._tTarget._height / _loc2_ * this._tTarget.maxscroll;
- this.setScrollProperties(_loc3_,0,this._tTarget.maxscroll);
- }
- function set scrollPosition(nScrollPosition)
- {
- this.mcHolder.mcThumb._y = nScrollPosition * (this.mcHolder.mcTrack._height - this.mcHolder.mcThumb._height) / (this._nMax - this._nMin) + this.mcHolder.mcTrack._y;
- if(this.mcHolder.mcThumb._y + this.mcHolder.mcThumb._height > this.mcHolder.mcDownArrow._y)
- {
- this.mcHolder.mcThumb._y = this.mcHolder.mcDownArrow._y - this.mcHolder.mcThumb._height;
- }
- }
- function get scrollPosition()
- {
- return Math.round((this.mcHolder.mcThumb._y - this.mcHolder.mcTrack._y) / (this.mcHolder.mcTrack._height - this.mcHolder.mcThumb._height) * (this._nMax - this._nMin));
- }
- function arrange()
- {
- if(this._nSize == undefined)
- {
- return undefined;
- }
- super.arrange();
- this._xscale = 100;
- this._yscale = 100;
- if(this._bHorizontal)
- {
- this.mcHolder._rotation = -90;
- }
- this.mcHolder.mcTrack._height = Math.max(this._nSize - this.mcHolder.mcUpArrow._height - this.mcHolder.mcDownArrow._height,0);
- this.mcHolder.mcTrack._y = this.mcHolder.mcUpArrow._height;
- this.mcHolder.mcDownArrow._y = this.mcHolder.mcTrack._y + this.mcHolder.mcTrack._height;
- this.mcHolder.mcThumb._y = this.mcHolder.mcTrack._y;
- this.mcHolder.mcThumb._x = 2;
- if(this.mcHolder.mcThumb._height > this.mcHolder.mcTrack._height)
- {
- this.mcHolder.mcThumb._visible = false;
- }
- else
- {
- this.mcHolder.mcThumb._visible = true;
- }
- }
- function size()
- {
- super.size();
- this._nSize = this.__height;
- this.arrange();
- }
- function set horizontal(bHorizontal)
- {
- this._bHorizontal = bHorizontal;
- this.arrange();
- }
- function init()
- {
- super.init();
- if(this._nMin == undefined)
- {
- this._nMin = 0;
- }
- if(this._nMax == undefined)
- {
- this._nMax = 100;
- }
- if(this._nPage == undefined)
- {
- this._nPage = 10;
- }
- }
- }
-