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

📄 customlistview.as

📁 flashget43的源代码 一个比较常用的下载程序
💻 AS
📖 第 1 页 / 共 2 页
字号:
_global.CustomListView.prototype.setPropHeight = function(inHeight) {	return this.setSize(inHeight, this.listHeight);};_global.CustomListView.prototype._addItemAt = function(inIdx, inItem) {	var itemBounds = this.getItemBounds(inItem);	var itemY = this.totalHeight;	if (inIdx < this.itemWrapperList.length) {		itemY = this.itemWrapperList[inIdx].y;		for (var i = inIdx; i < this.itemWrapperList.length; i ++) {			this.itemWrapperList[i].y += itemBounds.height;		}	}	var itemWrapper = new CItemWrapper(inItem, itemY, itemBounds);	this.totalHeight += itemBounds.height;	if (this.maxWidth < itemBounds.width) {		this.maxWidth = itemBounds.width;	}	if (this.maxHeight < itemBounds.height) {		this.maxHeight = itemBounds.height;	}	this.itemWrapperList.splice(inIdx, 0, itemWrapper);};_global.CustomListView.prototype._addItemsAt = function(inIdx, inItemList) {	var startItemY = this.totalHeight;	if (inIdx < this.itemWrapperList.length) {		startItemY = this.itemWrapperList[inIdx].y;	}	var itemsHeight = 0;	for (var i = 0; i < inItemList.length; i ++) {		var itemBounds = this.getItemBounds(inItemList[i]);		var itemWrapper = new CItemWrapper(inItemList[i], startItemY + itemsHeight, itemBounds);		itemsHeight += itemBounds.height;		this.itemWrapperList.splice(inIdx + i, 0, itemWrapper);		if (this.maxWidth < itemBounds.width) {			this.maxWidth = itemBounds.width;		}		if (this.maxHeight < itemBounds.height) {			this.maxHeight = itemBounds.height;		}	}	for (var i = inIdx + inItemList.length; i < this.itemWrapperList.length; i ++) {		this.itemWrapperList[i].y += itemsHeight;	}	this.totalHeight += itemsHeight;};_global.CustomListView.prototype._removeItemsAt = function(inStartIdx, inEndIdx) {	var itemsHeight = 0;	for (var i = inStartIdx; i <= inEndIdx; i ++) {		var itemWrapper = this.itemWrapperList[i];		itemsHeight += itemWrapper.bounds.height;	}		this.totalHeight -= itemsHeight;	if (this.totalHeight - this.y < this.listHeight) {		this.y = Math.max(this.totalHeight - this.listHeight, 0);	}		for (var i = inEndIdx + 1; i < this.itemWrapperList.length; i ++) {		this.itemWrapperList[i].y -= itemsHeight;	}		this.itemWrapperList.splice(inStartIdx, inEndIdx - inStartIdx + 1);		this.maxHeight = 0;	this.maxWidth = 0;	for (var i = 0; i < this.itemWrapperList.length; i ++) {		if (this.maxWidth < this.itemWrapperList[i].bounds.width) {			this.maxWidth = this.itemWrapperList[i].bounds.width;		}		if (this.maxHeight < this.itemWrapperList[i].bounds.height) {			this.maxHeight = this.itemWrapperList[i].bounds.height;		}	}		if (this.maxWidth - this.x < this.listWidth) {		this.x = Math.max(this.maxWidth - this.listWidth, 0);	}};_global.CustomListView.prototype.paint = function() {	if (this.itemWrapperList.length == 0 || !this.allow_paint) return;		//trace(' <<< Call PAINT >>> ' + this.itemWrapperList.length);			for (var i = 0; i < this.mcList.length; i ++) this.mcList[i].remove = true;	if (this.itemWrapperList.length > 0) {		this.freeDepthLevel = this.mcList.length;		this.firstShownIdx = this.findItemWrappeIdxForY(this.y);		itemWrapperIdx = this.firstShownIdx;		while (itemWrapperIdx < this.itemWrapperList.length) {			var itemWrapper = this.itemWrapperList[itemWrapperIdx];			if (itemWrapper.y > this.y + this.listHeight) {				break;			}			var existingMCWrapper = this.mcHash[itemWrapper.hash];			var itemMC = null;			if (existingMCWrapper != null) {				existingMCWrapper.remove = false;				itemMC = existingMCWrapper.mc;			} else {				this.customListView_items.attachMovie(itemWrapper.item.getMC(), 'customListView_' + itemWrapper.hash, this.getFreeDepthLevel());				itemMC = this.customListView_items['customListView_' + itemWrapper.hash];				var mcWrapper = new CMCWrapper(itemMC, itemWrapper);				this.mcList.push(mcWrapper);				this.mcHash[itemWrapper.hash] = mcWrapper;				itemWrapper.mcWrapper = mcWrapper;				itemMC.applyStyle(this.style);				itemMC.setLanguage(this.language);				itemMC.setData(itemWrapper.item);			}						if ((itemWrapper.item.setWidth == null) || (itemWrapper.item.getWidth == null) || (itemWrapper.item.getHeight == null)) {				//if item itself does not support width/height calculation, set mc width.				var prefferableWidth = this.listWidth - (this.vScrollBar._visible ? this.vScrollBar._width : 0);				var maxWidth = this.hScrollBar.maxPos + this.hScrollBar.pageSize;				itemMC.setWidth(prefferableWidth, this.hScrollBar._visible ? maxWidth : prefferableWidth);			}						itemMC._x = - this.x - itemWrapper.bounds.x;			itemMC._y = itemWrapper.y - this.y - itemWrapper.bounds.y;						itemWrapperIdx ++;		}	}	for (var i = 0; i < this.mcList.length; i ++) {		if (this.mcList[i].remove) {			this.mcList[i].mc.removeMovieClip();			this.mcHash[this.mcList[i].itemWrapper.hash] = null;			for (var j = i + 1; j < this.mcList.length; j ++) {				this.mcList[j].mc.swapDepths(this.mcList[j].mc.getDepth() - 1);			}			this.mcList.splice(i, 1);			i --;		}	}		this.resetItems();//realign module	};_global.CustomListView.prototype.paintHorizontal = function() {	for (var i = 0; i < this.mcList.length; i ++) {		var itemMC = this.mcList[i].mc;		itemMC._x = - this.x - this.itemWrapperList[this.firstShownIdx + i].bounds.x;	}};_global.CustomListView.prototype.findItemWrappeIdxForY = function(inY) {	var startIdx = Math.floor(inY / this.maxHeight);	for (var i = startIdx; i < this.itemWrapperList.length; i ++) {		var itemWrapper = this.itemWrapperList[i];		if ((itemWrapper.y <= inY) && (itemWrapper.y + itemWrapper.bounds.height > inY)) {			return i;		}	}	return -1;};_global.CustomListView.prototype.getItemBounds = function(inItem) {	var itemBounds = new Object();	var prefferableWidth = this.listWidth - (this.vScrollBar._visible ? this.vScrollBar._width : 0);	var maxWidth = this.hScrollBar.maxPos + this.hScrollBar.pageSize;	var itemRef = this.getItemRef(inItem);		if ((inItem.setWidth != null) && (inItem.getWidth != null) && (inItem.getHeight != null)) {		//if item iself supports width/height calculation, do not create mc for this item		inItem.setWidth(prefferableWidth, this.hScrollBar._visible ? maxWidth : prefferableWidth);				var bounds = inItem.getBounds();		itemBounds.x = bounds.xMin;		itemBounds.y = bounds.yMin;				itemBounds.width = inItem.getWidth();		itemBounds.height = Math.floor(inItem.getHeight());	}else if(itemRef != undefined) {		itemRef.setWidth(prefferableWidth, this.hScrollBar._visible ? maxWidth : prefferableWidth);		itemRef.setData(inItem);				var bounds = itemRef.getBounds();		if(inItem.getMC() == 'ItemUser') bounds = itemRef.button.getBounds();		itemBounds.x = bounds.xMin;		itemBounds.y = bounds.yMin;				itemBounds.width = itemRef._width;		itemBounds.height = Math.floor(itemRef.button._height);	}else {		//otherwise, create a corresponding mc to find item dimensions.		var testDepthItem = this.customListView_testMC[inItem.getMC() + '_mc'];		if (testDepthItem == null) {			this.customListView_testMC.attachMovie(inItem.getMC(), inItem.getMC() + '_mc', this.testMCDepth);			testDepthItem = this.customListView_testMC[inItem.getMC() + '_mc'];			this.testMCDepth ++;			testDepthItem._visible = false;		}		testDepthItem.setWidth(prefferableWidth, this.hScrollBar._visible ? maxWidth : prefferableWidth);		testDepthItem.setData(inItem);		var bounds = itemRef.getBounds();		if(inItem.getMC() == 'ItemUser') bounds = itemRef.button.getBounds();		itemBounds.x = bounds.xMin;		itemBounds.y = bounds.yMin;		itemBounds.width = testDepthItem._width;		itemBounds.height = Math.floor(testDepthItem.button._height);	}	return itemBounds;};_global.CustomListView.prototype.getFreeDepthLevel = function() {	return (this.freeDepthLevel ++);};_global.CustomListView.prototype.updateScrollBars = function() {	this.updateVScrollBar();	this.updateHScrollBar();	if (this.vScrollBar._visible && this.hScrollBar._visible) {		this.scrollBarRect._visible = true;	} else {		this.scrollBarRect._visible = false;	}};_global.CustomListView.prototype.updateVScrollBar = function() {	var changedVisibility = false;	if (this.totalHeight - this.listHeight + (this.hScrollBar._visible ? this.hScrollBar._height : 0) <= 0) {		if (this.vScrollBar._visible) {			this.vScrollBar.setEnabled(false);			this.vScrollBar._visible = false;			changedVisibility = true;		}	} else {		this.vScrollBar.setChangeHandler(null);		if (!this.vScrollBar._visible) {			this.vScrollBar.setEnabled(true);			this.vScrollBar._visible = true;			changedVisibility = true;		}		var size = this.listHeight - (this.hScrollBar._visible ? this.hScrollBar._height : 0);		if (this.vScrollBar._height != size)  {			this.vScrollBar.setSize(size);		}		this.vScrollBar.setScrollProperties(size, 0, this.totalHeight - size);		if (this.y != this.vScrollBar.getScrollPosition()) {			this.vScrollBar.setScrollPosition(this.y);		}		this.vScrollBar.setChangeHandler('vScrollHandler');	}	if (changedVisibility) {		this.resetItems();		this.updateVScrollBar();		this.updateHScrollBar();	}};_global.CustomListView.prototype.updateHScrollBar = function() {	var changedVisibility = false;	if (this.maxWidth <= this.listWidth - (this.vScrollBar._visible ? this.vScrollBar._width : 0)) {		if (this.hScrollBar._visible) {			this.hScrollBar.setEnabled(false);			this.hScrollBar._visible = false;			changedVisibility = true;		}	} else {		this.hScrollBar.setChangeHandler(null);		if (!this.hScrollBar._visible) {			this.hScrollBar.setEnabled(true);			this.hScrollBar._visible = true;			changedVisibility = true;		}		var size = this.listWidth - (this.vScrollBar._visible ? this.vScrollBar._width : 0);		if (this.hScrollBar._width != size) {			this.hScrollBar.setSize(size);		}		this.hScrollBar.setScrollProperties(size, 0, this.maxWidth - size);		if (this.x != this.hScrollBar.getScrollPosition()) {			this.hScrollBar.setScrollPosition(this.x);		}		this.hScrollBar.setChangeHandler('hScrollHandler');	}	if (changedVisibility) {		this.updateVScrollBar();	}};_global.CustomListView.prototype.vScrollHandler = function() {	this.y = this.vScrollBar.getScrollPosition();	this.paint();};_global.CustomListView.prototype.hScrollHandler = function() {	this.x = this.hScrollBar.getScrollPosition();	this.paintHorizontal();};_global.CustomListView.prototype.drawListBorder = function() {	this.customListView_border.clear();	this.customListView_border.lineStyle(1, this.style.borderColor, 100);	this.customListView_border.moveTo(0, 0);	this.customListView_border.lineTo(this.listWidth, 0);	this.customListView_border.lineTo(this.listWidth, this.listHeight);	this.customListView_border.lineTo(0, this.listHeight);	this.customListView_border.lineTo(0, 0);};_global.CustomListView.prototype.resetItems = function() {		//recalculate total items height.	this.maxHeight = 0;	this.maxWidth = 0;	this.totalHeight = 0;	this.x = 0;	var itemY = 0;		for (var i = 0; i < this.itemWrapperList.length; i ++) {		var itemBounds = this.getItemBounds(this.itemWrapperList[i].item);		this.itemWrapperList[i].y = itemY;		this.itemWrapperList[i].bounds = itemBounds;		itemY += itemBounds.height;		this.totalHeight += itemBounds.height;		if (this.maxWidth < itemBounds.width) {			this.maxWidth = itemBounds.width;		}		if (this.maxHeight < itemBounds.height) {			this.maxHeight = itemBounds.height;		}	}		if (this.totalHeight - this.y < this.listHeight) {		this.y = Math.max(this.totalHeight - this.listHeight, 0);	}	if (this.maxWidth - this.x < this.listWidth) {		this.x = Math.max(this.maxWidth - this.listWidth, 0);	}		//allign module		if( this['module'] && this['module']._width > 0)	{			var x,y; 		var w,h;		w = this.bWidth;		h = this.bHeight;				if(_level0.ini.module.stretch)		{						this['module']._x = 0;				this['module']._y = itemY;						/*			this['module']._xscale = (this.listWidth/w) * 100;				this['module']._yscale = ((this.listHeight - itemY)/h) * 100;			*/						//_global.FlashChatNS.chatUI.callModuleFunc('mOnModuleWindowResize', {width : this.listWidth, height : (this.listHeight - itemY)});		}		else		{ 			switch(_level0.ini.module.anchor){			case '1' :				x = 0;				y = itemY;								break;							case '2' :				x = (this.listWidth  - w);				y = itemY;												break;							case '3' :				x = 0;				y = Math.max(itemY, itemY + (this.listHeight - itemY - h));				break;							case '4' :				x = (this.listWidth - w);				y = Math.max(itemY, itemY + (this.listHeight - itemY - h));								break;							default : 				x = (this.listWidth  - w) / 2;				y = Math.max(itemY, itemY + (this.listHeight - itemY - h) / 2);				break;			}					this['module']._x = x;				this['module']._y = y;		}				}	//---	};_global.CItemWrapper = function(inItem, inY, inBounds) {	this.item = inItem;	this.y = inY;	this.bounds = inBounds;	this.hash = '' + Math.round(1000000000 * Math.random());	this.mcWrapper = null;};_global.CMCWrapper = function(inMC, inItemWrapper) {	this.mc = inMC;	this.itemWrapper = inItemWrapper;	this.remove = false;};Object.registerClass('CustomListView', _global.CustomListView);#endinitclip

⌨️ 快捷键说明

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