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

📄 itemstorecomponent.as

📁 This is a Flex UIComponent that can be used 谋n a FLEX 3 mxml application as component written in act
💻 AS
字号:
package mx.item.component
{
	import flash.display.Loader;
	import flash.events.MouseEvent;
	import flash.net.URLRequest;
	
	import mx.controls.Alert;
	import mx.core.UIComponent;
	import mx.item.collection.StoreItemCollection;
	import mx.item.data.StoreItem;
	import mx.item.view.StoreItemCollectionView;
	import mx.item.view.StoreItemView;

 
public class ItemStoreComponent extends UIComponent 
{
 
	
 
	
	
	// ---- constructor  ----------------------------------------------------------------------------------
 

            
			private var _storeCollectionView:StoreItemCollectionView;
			private var _storeCollection:StoreItemCollection;
			private var _cartCollectionView:StoreItemCollectionView;
			private var _cartCollection:StoreItemCollection;
			private var _trachCanIcon:Loader;
			
			
		 
			private var _storeItemViewCopy:StoreItemView;
			private var _cartItemViewCopy:StoreItemView;
	        private var _UIC:UIComponent = new UIComponent;
 
		public function ItemStoreComponent()
		{   
		    
		  
				 addChild(_UIC);
			 
			 
			var item:StoreItem = new StoreItem("888888 1","Description 1","Size 1","images/p1.jpg");
			this._storeCollection = new StoreItemCollection();
			this._storeCollection.addItem(item);
			
			this._storeCollectionView = new StoreItemCollectionView(this._storeCollection, onMouseDownStore);
			_UIC.addChild(this._storeCollectionView);
			
			item = new StoreItem("111111","Description 2","Size 2","images/p2.jpg");
			this._storeCollection.addItem(item);
			item = new StoreItem("222222","Description 2","Size 2","images/p2.jpg");
			this._storeCollection.addItem(item);
			item = new StoreItem("33333 2","Description 2","Size 2","images/p2.jpg");
			this._storeCollection.addItem(item);
			item = new StoreItem("444444 2","Description 2","Size 2","images/p2.jpg");
			this._storeCollection.addItem(item);
			item = new StoreItem("55555 2","Description 2","Size 2","images/p2.jpg");
			this._storeCollection.addItem(item);
			item = new StoreItem("666666 2","Description 2","Size 2","images/p2.jpg");
			this._storeCollection.addItem(item);
			item = new StoreItem("77777 2","Description 2","Size 2","images/p2.jpg");
			this._storeCollection.addItem(item);
			
			this._cartCollection = new StoreItemCollection();
			this._cartCollectionView = new StoreItemCollectionView(this._cartCollection, onMouseDownCart);
			 
			this._cartCollectionView.x = 400;
			_UIC.addChild(this._cartCollectionView);
		    this._trachCanIcon = new Loader();
		    var request:URLRequest = new URLRequest("images/trash_empty.png");
		    this._trachCanIcon.load(request);
		    this._trachCanIcon.x = 800;
		    this._trachCanIcon.y = 300;
		    _UIC.addChild(this._trachCanIcon);
		    
			

			 
		}
		
	/*
		private function onMouseDownStore(event:MouseEvent):void
		{  trace("Mouse DOWN");
		 try {
			   this._storeItemViewCopy = StoreItemView(event.currentTarget).clone();
	          this._storeItemViewCopy.addEventListener(MouseEvent.MOUSE_UP,onMouseUpStore);
	            
	           _UIC.addChild(this._storeItemViewCopy);
		       _UIC._storeItemViewCopy.startDrag();
		     }
		      catch(ex:Error) 
		            {Alert.show(ex.message.toString());}
	     }
        
        private function onMouseDownCart(event:MouseEvent):void {
        	try {
             	  this._cartItemViewCopy= StoreItemView(event.currentTarget).clone();
                  this._cartItemViewCopy.addEventListener(MouseEvent.MOUSE_UP,onMouseUpCart);
		          _UIC.addChild(this._cartItemViewCopy);
		          this._cartItemViewCopy.startDrag();
				}
		         catch(ex:Error) 
		               {Alert.show(ex.message.toString());}
		   }
        
        private function onMouseUpCart(event:MouseEvent):void {
        	try {
                    this._cartItemViewCopy.stopDrag();
                    if(this._cartItemViewCopy.hitTestObject(this._trachCanIcon)) 
      	                 { this._cartCollection.removeItem(this._cartItemViewCopy.data); }
	  	             _UIC.removeChild(this._cartItemViewCopy);
          			}
		         catch(ex:Error) 
		               {Alert.show(ex.message.toString());}
		   }
          
          
          
          
        private function onMouseUpStore(event:MouseEvent):void { trace("Mouse UP");
        	try {
                  this._storeItemViewCopy.stopDrag();
                  if(this._storeItemViewCopy.hitTestObject(this._cartCollectionView)) 
                      { this._cartCollection.addItem(this._storeItemViewCopy.data.clone()); }
	              _UIC.removeChild(this._storeItemViewCopy);
	            }
	            catch(ex:Error) 
		               {Alert.show(ex.message.toString());}
           }		
		
	*/
	
		private function onMouseDownStore(event:MouseEvent):void
		{trace("DownStore");
		try{
		var itemView:StoreItemView = StoreItemView(event.currentTarget);
		var itemViewCopy:StoreItemView = itemView.clone();
		itemViewCopy.addEventListener(MouseEvent.MOUSE_UP,onMouseUpStore);
		_UIC.addChild(itemViewCopy);
		itemViewCopy.startDrag();
		} catch(ex:Error) {Alert.show("Error:"+ex.message.toString());8}
        }
        
        private function onMouseDownCart(event:MouseEvent):void {
        trace("DownCart");
        	
        	var itemView:StoreItemView = StoreItemView(event.currentTarget);
		var itemViewCopy:StoreItemView = itemView.clone();
		itemViewCopy.addEventListener(MouseEvent.MOUSE_UP,onMouseUpCart);
		_UIC.addChild(itemViewCopy);
		itemViewCopy.startDrag();
        }
        
        private function onMouseUpCart(event:MouseEvent):void {
        	    trace("UpCart"); 
        	     	var itemView:StoreItemView = StoreItemView(event.currentTarget);
        	itemView.stopDrag();
        			if(itemView.hitTestObject(_trachCanIcon)) {
			_cartCollection.removeItem(	itemView.data);
		}
	      _UIC.removeChild(itemView);	 
        }
        
        
        private function onMouseUpStore(event:MouseEvent):void {
        	trace("UpStore");
        	var itemView:StoreItemView = StoreItemView(event.currentTarget);
        	itemView.stopDrag();
        			if(itemView.hitTestObject(_cartCollectionView)) {
			_cartCollection.addItem(itemView.data.clone());
		}
		_UIC.removeChild(itemView);
		
        }	
        
     	
	
// Uygulama Sonu 		
}}

 

⌨️ 快捷键说明

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