home *** CD-ROM | disk | FTP | other *** search
- class components.ui.scrollbar.ScrollBar extends components.ui.GenericUIComponent
- {
- var eventListener;
- var event;
- var instCounter;
- var listeners;
- var dataObj;
- var scrollUpBtn;
- var scrollDownBtn;
- var upBtn;
- var downBtn;
- var scrollArea;
- var scrollAreaBtn;
- var drag;
- var dragBtn;
- var scrollbarBackground;
- var IvID;
- function ScrollBar()
- {
- super();
- this.eventListener = new components.ui.scrollbar.listeners.ScrollBarListener();
- this.eventListener.setHolder(this);
- this.event = new application.core.EventDispatcher();
- this.instCounter = 0;
- this.listeners = [];
- Object.registerClass("scrollUpBtn",components.ui.SimpleButtonLogic);
- Object.registerClass("scrollDownBtn",components.ui.SimpleButtonLogic);
- Object.registerClass("scrollAreaBtn",components.ui.scrollbar.core.ScrollByDragHeightLogic);
- application.core.KeyControl.getInstance().addListener(this.eventListener);
- application.core.FocusManager.getInstance().addListener(this.eventListener);
- }
- function onMouseWheel(delta)
- {
- if(application.core.KeyControl.getInstance().getEnabled() == true)
- {
- delta *= -1;
- if(delta > 0)
- {
- this.dataObj.scrollBar.scrollDirection = 1;
- }
- else
- {
- this.dataObj.scrollBar.scrollDirection = -1;
- }
- var _loc2_ = 0;
- while(_loc2_ < Math.abs(delta))
- {
- this.scrollOneStep();
- _loc2_ = _loc2_ + 1;
- }
- }
- }
- function init()
- {
- var _loc2_ = this.attachMovie("scrollbarBackground","scrollbarBackground",this.instCounter++);
- _loc2_._height = this.dataObj.scrollBar.height;
- this.dataObj.scrollBar.width = _loc2_._width;
- }
- function build()
- {
- var _loc2_ = this.attachMovie("scrollUpBtn","scrollUpBtn",this.instCounter++);
- _loc2_._width = this.dataObj.scrollBar.width;
- _loc2_.moveTo(0,0);
- this.dataObj.scrollBar.upBtnHeight = this.scrollUpBtn._height;
- this.dataObj.scrollBar.upBtnWidth = this.dataObj.scrollBar.width;
- _loc2_ = this.attachMovie("scrollDownBtn","scrollDownBtn",this.instCounter++);
- _loc2_._width = this.dataObj.scrollBar.width;
- _loc2_.moveTo(0,this.dataObj.scrollBar.height - _loc2_._height);
- this.dataObj.scrollBar.downBtnHeight = this.scrollDownBtn._height;
- this.dataObj.scrollBar.downBtnWidth = this.dataObj.scrollBar.width;
- _loc2_ = this.attachMovie("scrollAreaBtn","scrollAreaBtn",this.instCounter++);
- _loc2_.moveTo(0,this.dataObj.scrollBar.upBtnHeight);
- this.dataObj.scrollBar.scrollAreaHeight = this.scrollDownBtn._y - this.scrollUpBtn._height;
- this.dataObj.scrollBar.scrollAreaWidth = this.dataObj.scrollBar.width;
- _loc2_.setDataProvider(this.dataObj);
- _loc2_.setSize();
- if(this.dataObj.contentTyp == "TextField")
- {
- Object.registerClass("dragBtn",components.ui.scrollbar.core.LineDragLogic);
- }
- else
- {
- Object.registerClass("dragBtn",components.ui.scrollbar.core.PixelDragLogic);
- }
- _loc2_ = this.attachMovie("dragBtn","dragBtn",this.instCounter++);
- _loc2_.moveTo(0,this.dataObj.scrollBar.upBtnHeight);
- var _loc3_ = _loc2_.attachMovie("dragBtnTop","t",1);
- _loc3_.gotoAndStop(1);
- var _loc5_ = _loc2_.attachMovie("dragBtnCenter","c",2);
- _loc5_.gotoAndStop(1);
- _loc5_._y = _loc3_._height;
- _loc3_ = _loc5_;
- _loc5_ = _loc2_.attachMovie("dragBtnBottem","b",3);
- _loc5_.gotoAndStop(1);
- _loc5_._y = _loc3_._y + _loc3_._height;
- _loc2_.setDataProvider(this.dataObj);
- _loc2_.init();
- _loc2_.setSize();
- var _loc4_ = _loc2_.attachMovie("dragDeko","dragDeko",20);
- _loc4_._x = (_loc2_._width - _loc4_._width) / 2;
- _loc4_._y = (_loc2_._height - _loc4_._height) / 2;
- this.upBtn = new components.ui.scrollbar.listeners.UpBtnListener();
- this.upBtn.setHolder(this);
- this.scrollUpBtn.addListener(this.upBtn);
- this.downBtn = new components.ui.scrollbar.listeners.DownBtnListener();
- this.downBtn.setHolder(this);
- this.scrollDownBtn.addListener(this.downBtn);
- this.scrollArea = new components.ui.scrollbar.listeners.ScrollAreaBtnListener();
- this.scrollArea.setHolder(this);
- this.scrollAreaBtn.addListener(this.scrollArea);
- this.drag = new components.ui.scrollbar.listeners.DragBtnListener();
- this.drag.setHolder(this);
- this.dragBtn.addListener(this.drag);
- }
- function update()
- {
- var _loc2_ = this.scrollbarBackground;
- _loc2_._height = this.dataObj.scrollBar.height;
- _loc2_ = this.scrollDownBtn;
- _loc2_.moveTo(0,this.dataObj.scrollBar.height - _loc2_._height);
- this.dataObj.scrollBar.downBtnHeight = this.scrollDownBtn._height;
- this.dataObj.scrollBar.downBtnWidth = this.dataObj.scrollBar.width;
- _loc2_ = this.scrollAreaBtn;
- this.dataObj.scrollBar.scrollAreaHeight = this.scrollDownBtn._y - this.scrollUpBtn._height;
- this.dataObj.scrollBar.scrollAreaWidth = this.dataObj.scrollBar.width;
- _loc2_.setDataProvider(this.dataObj);
- _loc2_.setSize();
- _loc2_ = this.dragBtn;
- _loc2_.moveTo(0,this.dataObj.scrollBar.upBtnHeight);
- var _loc3_ = _loc2_.t;
- _loc3_.gotoAndStop(1);
- var _loc4_ = _loc2_.c;
- _loc4_.gotoAndStop(1);
- _loc4_._y = _loc3_._height;
- _loc3_ = _loc4_;
- _loc4_ = _loc2_.b;
- _loc4_.gotoAndStop(1);
- _loc4_._y = _loc3_._y + _loc3_._height;
- _loc2_.init();
- _loc2_.setSize();
- }
- function onScroll()
- {
- }
- function onScrollonKeyEvent(dir)
- {
- this.dataObj.scrollBar.scrollDirection = dir;
- this.scrollOneStep();
- }
- function addListener(holder)
- {
- this.event.addListener(holder);
- }
- function removeListener(holder)
- {
- this.event.removeListener(holder);
- }
- function scrollTo(pos)
- {
- if(pos > this.dataObj.content.contentToScroll)
- {
- pos = this.dataObj.content.contentToScroll;
- }
- this.dragBtn.setToPos(pos);
- pos = this.dragBtn.getPos();
- this.dataObj.scrollBar.dragPos = pos;
- this.event.dispatchEvent("onScroll",this.dataObj.scrollBar.dragPos);
- }
- function startScroll()
- {
- var _loc2_ = this.dragBtn.getSize();
- this.dragBtn.startDrag(false,0,this.scrollUpBtn._height,0,this.scrollDownBtn._y - _loc2_);
- this.IvID = setInterval(this,"scroll",0);
- }
- function scroll()
- {
- var _loc2_ = this.dragBtn.getPos();
- if(_loc2_ != this.dataObj.scrollBar.dragPos)
- {
- this.dataObj.scrollBar.dragPos = _loc2_;
- this.event.dispatchEvent("onScroll",this.dataObj.scrollBar.dragPos);
- this.onScroll();
- updateAfterEvent();
- }
- }
- function stopScroll()
- {
- clearInterval(this.IvID);
- delete this.IvID;
- this.dragBtn.stopDrag();
- }
- function startScrollOneStep(direction)
- {
- var _loc2_ = this.dataObj.scrollBar;
- if((direction == -1 && _loc2_.dragPos >= 2) | (direction == 1 && _loc2_.dragPos <= this.dataObj.content.maxScroll - 1))
- {
- _loc2_.scrollDirection = direction;
- _loc2_.dragPos = this.dragBtn.setPos(_loc2_.scrollDirection);
- this.event.dispatchEvent("onScroll",_loc2_.dragPos);
- this.onScroll();
- updateAfterEvent();
- this.IvID = setInterval(this,"waitForRelease",500);
- }
- }
- function waitForRelease()
- {
- clearInterval(this.IvID);
- delete this.IvID;
- this.IvID = setInterval(this,"scrollOneStep",60);
- }
- function scrollOneStep()
- {
- var _loc2_ = this.dataObj.scrollBar;
- if((_loc2_.scrollDirection == -1 && _loc2_.dragPos != 1) | (_loc2_.scrollDirection == 1 && _loc2_.dragPos != this.dataObj.content.maxScroll))
- {
- _loc2_.dragPos = this.dragBtn.setPos(_loc2_.scrollDirection);
- this.event.dispatchEvent("onScroll",_loc2_.dragPos);
- this.onScroll();
- updateAfterEvent();
- }
- else
- {
- this.stopScrollOneStep();
- }
- }
- function stopScrollOneStep()
- {
- clearInterval(this.IvID);
- delete this.IvID;
- }
- function startScrollByDragHeight()
- {
- this.scrollAreaBtn.setFinalScrollPos();
- this.IvID = setInterval(this,"ScrollByDragHeight",0);
- }
- function ScrollByDragHeight()
- {
- clearInterval(this.IvID);
- delete this.IvID;
- this.IvID = setInterval(this,"ScrollByDragHeight",150);
- var _loc2_ = this.dataObj.scrollBar;
- var _loc3_ = this.scrollAreaBtn.getNextPos();
- if(_loc2_.scrollDirection == -1 && _loc3_ >= _loc2_.finalScrollPos || _loc2_.scrollDirection == 1 && _loc3_ <= _loc2_.finalScrollPos)
- {
- this.dragBtn._y = _loc3_;
- this.scrollAreaBtn.update();
- this.dataObj.scrollBar.dragPos = this.dragBtn.getPos();
- this.event.dispatchEvent("onScroll",this.dataObj.scrollBar.dragPos);
- this.onScroll();
- updateAfterEvent();
- }
- else
- {
- this.dragBtn._y = _loc2_.finalScrollPos;
- this.stopScrollByDragHeight();
- this.scrollAreaBtn.update();
- this.dataObj.scrollBar.dragPos = this.dragBtn.getPos();
- this.event.dispatchEvent("onScroll",this.dataObj.scrollBar.dragPos);
- this.onScroll();
- updateAfterEvent();
- }
- }
- function stopScrollByDragHeight()
- {
- clearInterval(this.IvID);
- delete this.IvID;
- }
- function onUnload()
- {
- application.core.FocusManager.getInstance().removeListener(this.eventListener);
- application.core.KeyControl.getInstance().removeListener(this.eventListener);
- }
- }
-