storeitemcollection.as

来自「This is a Flex UIComponent that can be u」· AS 代码 · 共 43 行

AS
43
字号
package mx.item.collection
{
	import flash.events.Event;
	import flash.events.EventDispatcher;
	
	import mx.item.data.StoreItem;
	
	public class StoreItemCollection extends EventDispatcher
	{
		private var _collection:Array;
		
		public function get count():uint {
			return _collection.length;
		}
		public function StoreItemCollection()
		{
			_collection = new Array();
		}
		
		public function addItem(item:StoreItem):void {
			_collection.push(item);
			item.collection	= this;
			dispatchEvent(new Event(Event.CHANGE));
		}
		
		public function removeItem(item:StoreItem):void {
			var i:uint;
			
			for(i = 0; i <_collection.length; i++) {
				if(_collection[i] == item) {
					_collection.splice(i,1);
					break; // Break For Dongusunu Termınate Edıcektır 
				}
			}
			dispatchEvent(new Event(Event.CHANGE));
		}
		
		public function getItem(index:uint):StoreItem {
			return StoreItem(_collection[index]);
		}

	}
}

⌨️ 快捷键说明

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