⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vertscrollpanel.as

📁 国外强大的xml相册
💻 AS
字号:
//***********************VertScrollPanel class*************************
import pssclasses.splitpanel.scrollpane.*;
class VertScrollPanel extends ScrollBasicAction {
	//**************define variables**************
	//**************define metods****************
	private function VertScrollPanel() {
	}
	public function scrollBGSetSize(__size:Number):Void {
		scrollBG_mc._height = __size;
		// scroll bg
		center_mc._y = Math.floor(top_mc._height)-2;
		center_mc._height = Math.floor(__size-top_mc._height*2)+3;
		bott_mc._y = Math.floor(__size-bott_mc._height);
		//set SIZEORIENTIR for watch scroll
		SIZEORIENTIR = __size;
		//watch content
		watchContent();
	}
	//****************************WATCH ON CONTENT********************
	public function set contentContainer(cont:MovieClip):Void {
		CONTENT = cont;
		//*****************when press**************
		scrolingEventContent();
	}
	public function watchContent():Void {
		//*******************resize scroll bulb**********************
		// border when goriz scroll is visible
		var gorScrollHeight:Number = Math.ceil(__this._width);
		// content height
		var contHeight:Number = CONTENT._height+Balance;
		// contenc tail
		//SIZEORIENTIR = scroll BG height
		var diferentH:Number = contHeight-SIZEORIENTIR;
		// start scroll bulb size
		var bulbSize:Number = SIZEORIENTIR;
		// bulb size 
		bulbSize = Math.round(bulbSize-diferentH);
		// scroll height - scroll height
		var scrollWay:Number = SIZEORIENTIR-scrollBulb_mc._height;
		// bulb place
		//****************************visible scroll*******************
		if (contHeight<SIZEORIENTIR) {
			__this._visible = false;
			SCROLLPANE.vScrollVisible = false;
		} else {
			__this._visible = true;
			SCROLLPANE.vScrollVisible = true;
			// set bulb size
			bulbSetSize(bulbSize);
		}
		// if scroll y and height > scroll bg
		if (SIZEORIENTIR<scrollBulb_mc._y+scrollBulb_mc._height) {
			scrollBulb_mc._y -= scrollBulb_mc._y+scrollBulb_mc._height-SIZEORIENTIR;
		}
		// content place                              
		if (diferentH<=-(CONTENT._y) && CONTENT._y<0) {
			CONTENT._y = -(diferentH);
		}
		if (CONTENT._y>0) {
			CONTENT._y = 0;
		}
		// percent content tail             
		var percentContentPosition:Number = Math.round(-(CONTENT._y)/diferentH*100);
		// pixel from content tail percent for bulb position
		var percentBulbPosition:Number = Math.round((SIZEORIENTIR-scrollBulb_mc._height)/100*percentContentPosition);
		scrollBulb_mc._y = percentBulbPosition;
	}
	//********************************SCROLING*******************************
	private function scrolingEventContent():Void {
		var scrollFull:MovieClip = __this;
		var scrollPane:MovieClip = __this._parent;
		var _CONTENT:MovieClip = CONTENT;
		var maxPoint:Number = 0;
		var pointClik:Number = 0;
		var __bulb:MovieClip = scrollBulb_mc;
		var diferent:Number;
		var ziroPosition:Number;
		var percentBulbPosition:Number;
		var percentContentPosition:Number;
		var scrollWay:Number;
		var _Balance:Number = Balance;
		//***********************scroll content*******************
		function scrollContent():Void {
			//*******************cointainer for scroll bulb**************************
			__bulb._y = scrollFull._ymouse-pointClik;
			if (__bulb._y<=1) {
				__bulb._y = 1;
			}
			if (__bulb._y+__bulb._height>=maxPoint) {
				__bulb._y = maxPoint-__bulb._height-1;
			}
			//****end*************cointainer for scroll bulb**************************                                            
			//**************scroling process
			//*******calculate percent scroll bulb position and how much pixel this percent from deferent size********
			percentBulbPosition = Math.round(__bulb._y/scrollWay*100);
			// percent scroll bulb position to pixcel for content position
			percentContentPosition = Math.round(diferent/100*percentBulbPosition);
			// ********end calculate***********
			_CONTENT._y = -(percentContentPosition);
			//****end*******scroling process 
			updateAfterEvent();
		}
		//*****end***************scroll content*******************
		scrollBulb_mc.onPress = function() {
			Selection.setFocus(this);
			//poind clik on bulb
			pointClik = scrollFull._ymouse-this._y;
			maxPoint = scrollFull.scrollBG_mc._height;
			diferent = _CONTENT._height-scrollFull._height+_Balance;
			ziroPosition = Math.round(__bulb._height);
			scrollWay = maxPoint-ziroPosition;
			// set interval
			INTERINDEX = setInterval(scrollContent, 5);
			//this.onMouseMove = scrollContent;
		};
		//*********************************KEY EVENT*********************
		// browser if activ
		var _BROWSER:MovieClip = BROWSER;
		var keyListener:Object = new Object();
		Key.addListener(keyListener);
		keyListener.onKeyDown = function() {
			if (Key.isDown(Key.DOWN) || Key.isDown(Key.UP)) {
				if (_BROWSER.ActivBrowser) {
					var KEYPress:Boolean = false;
					//poind clik on bulb
					pointClik = scrollFull._ymouse-this._y;
					maxPoint = scrollFull.scrollBG_mc._height;
					diferent = _CONTENT._height-scrollFull._height+_Balance;
					ziroPosition = Math.round(__bulb._height);
					scrollWay = maxPoint-ziroPosition;
					//**************************DOWN*************************************
					if (Key.isDown(Key.DOWN)) {
						__bulb._y += 5;
						KEYPress = true;
					}
					//**************************UP*************************************                          
					if (Key.isDown(Key.UP)) {
						__bulb._y -= 5;
						KEYPress = true;
					}
					//**************scroling process                       
					if (KEYPress) {
						//*****************cointainer for scroll bulb**************************      
						if (__bulb._y<=1) {
							__bulb._y = 1;
						}
						if (__bulb._y+__bulb._height>=maxPoint) {
							__bulb._y = maxPoint-__bulb._height-1;
						}
						//****end*************cointainer for scroll bulb**************************                              
						//*******calculate percent scroll bulb position and how much pixel this percent from deferent size********
						percentBulbPosition = Math.round(__bulb._y/scrollWay*100);
						// percent scroll bulb position to pixcel for content position
						percentContentPosition = Math.round(diferent/100*percentBulbPosition);
						// ********end calculate***********
						_CONTENT._y = -(percentContentPosition);
					}
					//****end*******scroling process   
					updateAfterEvent();
				}
			}
		};
		//***********END*****************KEY EVENT*********************
		//*********************************MOUSE WHEEL EVENT*********************
		var mouseListener:Object = new Object();
		Mouse.addListener(mouseListener);
		mouseListener.onMouseWheel = function(delta:Number, scrollTarget:String) {
			if (_BROWSER.ActivBrowser && scrollTarget == scrollPane.WheelFace) {
				//point clik on bulb
				pointClik = scrollFull._ymouse-this._y;
				maxPoint = scrollFull.scrollBG_mc._height;
				diferent = _CONTENT._height-scrollFull._height+_Balance;
				ziroPosition = Math.round(__bulb._height);
				scrollWay = maxPoint-ziroPosition;
				//**************scroling process       
				__bulb._y -= delta*2;
				//*****************cointainer for scroll bulb**************************      
				if (__bulb._y<=1) {
					__bulb._y = 1;
				}
				if (__bulb._y+__bulb._height>=maxPoint) {
					__bulb._y = maxPoint-__bulb._height-1;
				}
				//****end*************cointainer for scroll bulb**************************                              
				//*******calculate percent scroll bulb position and how much pixel this percent from deferent size********
				percentBulbPosition = Math.round(__bulb._y/scrollWay*100);
				// percent scroll bulb position to pixcel for content position
				percentContentPosition = Math.round(diferent/100*percentBulbPosition);
				// ********end calculate***********
				_CONTENT._y = -(percentContentPosition);
				//****end*******scroling process 
				updateAfterEvent();
			}
		};
		//**********************Klick on BG**************************
		scrollBG_mc.onPress = function() {
			Selection.setFocus(this);
			//poind clik on bulb
			pointClik = scrollFull._ymouse-(__bulb._height/2);
			maxPoint = scrollFull.scrollBG_mc._height;
			diferent = _CONTENT._height-scrollFull._height+_Balance;
			ziroPosition = Math.round(__bulb._height);
			scrollWay = maxPoint-ziroPosition;
			__bulb._y = pointClik;
			//*****************cointainer for scroll bulb**************************      
			if (__bulb._y<=1) {
				__bulb._y = 1;
			}
			if (__bulb._y+__bulb._height>=maxPoint) {
				__bulb._y = maxPoint-__bulb._height-1;
			}
			//****end*************cointainer for scroll bulb**************************                              
			//*******calculate percent scroll bulb position and how much pixel this percent from deferent size********
			percentBulbPosition = Math.round(__bulb._y/scrollWay*100);
			// percent scroll bulb position to pixcel for content position
			percentContentPosition = Math.round(diferent/100*percentBulbPosition);
			// ********end calculate***********
			_CONTENT._y = -(percentContentPosition);
			//****end*******scroling process 
			updateAfterEvent();
		};
	}
	//*******end*********************SCROLING*******************************
	//*******end***class*****************
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -