flex学习笔记-布局

阅读更多
flex中设置图片平铺



flex填充:







这里如果把embed取消掉,就不会填充任何东西,不知道什么原因?















stroke表示边框
fill就是填充色了
GradientEntry中的ratio不太明白啥意思

下面是一个弹出框:
本来可以不添加group来填充颜色的,由于我重写了bordercontainer的皮肤,导致这里再设置bgcolor不起作用,还不知道什么原因?


	
	
		
	
	
	
		
	
	
		
	
	
	
		
			
				
			
			
				
					
						
					
				
			
		
	
	
	
		
			
				
					
						
					
				
			
		
	
	
	
		
	



有关重写皮肤,皮肤主要作用是来布局对应组件和设置样式,但同样也可以出发事件,这里需要注意到是,如果要扩展原有组件添加的元素的变量名称需要和皮肤中的一样
如:组件中有一个元素:
[SkinPart(required="false")]
public var btnMin:Image;
皮肤中就应该有对应的
width="18" height="18" right="27" top="7"/>
类型也需要相同,而且[SkinPart(required="false")]这句话不能少,原因也不清楚,先用着吧

下面为重写的titleWindow组件,添加了最小化按钮,是项目中用到的,直接帖过来的
组件:


	
		
	
	
	
		
		
		
		
	
	
	
		theMinWidth?xPlus:theMinWidth;
							this.height=yPlus>theMinHeight?yPlus:theMinHeight;
							break;
						case SIDE_LEFT+SIDE_TOP:
							this.width=this.width-xPlus>theMinWidth?this.width-xPlus:theMinWidth;
							this.height=this.height-yPlus>theMinHeight?this.height-yPlus:theMinHeight;
							this.x=this.width>theMinWidth?FlexGlobals.topLevelApplication.mouseX:this.x;
							this.y=this.height>theMinHeight?FlexGlobals.topLevelApplication.mouseY:this.y;
							break;
						case SIDE_LEFT+SIDE_BOTTOM:
							this.width=this.width-xPlus>theMinWidth?this.width-xPlus:theMinWidth;
							this.height=yPlus>theMinHeight?yPlus:theMinHeight;
							this.x=this.width>theMinWidth?FlexGlobals.topLevelApplication.mouseX:this.x;
							break;
						case SIDE_RIGHT+SIDE_TOP:
							this.width=xPlus>theMinWidth?xPlus:theMinWidth;
							this.height=this.height-yPlus>theMinHeight?this.height-yPlus:theMinHeight;
							this.y=this.height>theMinHeight?FlexGlobals.topLevelApplication.mouseY:this.y;
							break;
						case SIDE_RIGHT:
							this.width=xPlus>theMinWidth?xPlus:theMinWidth;
							break;
						case SIDE_LEFT:
							this.width=this.width-xPlus>theMinWidth?this.width-xPlus:theMinWidth;
							this.x=this.width>theMinWidth?FlexGlobals.topLevelApplication.mouseX:this.x;
							break;
						case SIDE_BOTTOM:
							this.height=yPlus>theMinHeight?yPlus:theMinHeight;
							break;
						case SIDE_TOP:
							this.height=this.height-yPlus>theMinHeight?this.height-yPlus:theMinHeight;
							this.y=this.height>theMinHeight?FlexGlobals.topLevelApplication.mouseY:this.y;
							break;
					}
				}
			}
			private function onMouseOut(event:MouseEvent):void
			{
				if(!isReSize&&this.theStatus==0)
				{
					theSide=0;
					onChangeCursor(CursorNull);
					this.isPopUp=true;
				}
			}
			private function onMouseMove(event:MouseEvent):void
			{
				if(!theStatus)
				{
					var point:Point=new Point();
					point=this.localToGlobal(point);
					var xPosition:Number=FlexGlobals.topLevelApplication.mouseX;
					var yPosition:Number=FlexGlobals.topLevelApplication.mouseY;
					if(xPosition>=(point.x+this.width-mouseMargin)&&yPosition>=(point.y+this.height-mouseMargin))
					{//右下
						onChangeCursor(CursorR,-9,-9);
						theSide=SIDE_RIGHT+SIDE_BOTTOM;
						this.isPopUp=false;
					}else if(xPosition<=(point.x+mouseMargin)&&yPosition<=(point.y+mouseMargin))
					{//左上
						onChangeCursor(CursorR,-9,-9);
						theSide=SIDE_LEFT+SIDE_TOP;
						this.isPopUp=false;
					}else if(xPosition<=(point.x+mouseMargin)&&yPosition>=(point.y+this.height-mouseMargin))
					{//左下
						onChangeCursor(CursorL,-9,-9);
						theSide=SIDE_BOTTOM+SIDE_LEFT;
						this.isPopUp=false;
					}else if(xPosition>=(point.x+this.width-mouseMargin)&&yPosition<=(point.y+mouseMargin))
					{//右上
						onChangeCursor(CursorL,-9,-9);
						theSide=SIDE_RIGHT+SIDE_TOP;
						this.isPopUp=false;
					}else if(xPosition>(point.x+this.width-mouseMargin))
					{//右
						onChangeCursor(CursorH,-9,-9);
						theSide=SIDE_RIGHT;
						this.isPopUp=false;
					}else if(xPosition<(point.x+mouseMargin))
					{//左
						onChangeCursor(CursorH,-9,-9);
						theSide=SIDE_LEFT;
						this.isPopUp=false;
					}else if(yPosition<(point.y+mouseMargin))
					{//上
						onChangeCursor(CursorV,-9,-9);
						theSide=SIDE_TOP;
						this.isPopUp=false;
					}
					else if(yPosition>(point.y+this.height-mouseMargin))
					{//下
						onChangeCursor(CursorV,-9,-9);
						theSide=SIDE_BOTTOM;
						this.isPopUp=false;
					}
					else
					{
						onChangeCursor(CursorNull);
						if(!isReSize&&theStatus==0)
						{
							theSide=0;
							this.isPopUp=true;
						}
					}
					event.updateAfterEvent();
				}
			}
			private function onChangeCursor(type:Class,xOffset:Number=0,yOffset:Number=0):void
			{
				if(currentType!=type)
				{
					currentType=type;
					CursorManager.removeCursor(CursorManager.currentCursorID);
					if(type!=null)
					{
						CursorManager.setCursor(type,2,xOffset,yOffset);
					}
				}
			}
			private function onSaveRestore():void
			{
				var point:Point=new Point();
				theOldPoint=this.localToGlobal(point);
				theOldWidth=this.width;
				theOldHeight=this.height;
			}
			private function onGetRestore():void
			{
				this.x=theOldPoint.x;
				this.y=theOldPoint.y
				this.width=theOldWidth;
				this.height=theOldHeight;
			}
		]]>
	



皮肤:


	
	
		
	 
	
	
		
	
	
	
		
		
		
		
		
		
	
	
	
	
	
	
	
		
		
		
			
			
				
					
				
			
		
		
		
		
			
			
				
					
				
			
		
		
		
		
			
				
				
			
		
		
		
		
		
			
				
				
			
		
		
		
		
		
			
				
			
			
			
				
				
				
					
						
							
							
							
						
					
				
				
				
				
					
						
							
							
						
					
					
						
							
							
							
						
					
				
				
				
				
					
						
					
				
				
				
				
				
				
				
				
				
				
				
				
				
			
			
			
			
			
			
			
			
			  
				
				
					
					
					
						
							
						
					
					
					
					
						
							
								
								
							
						
					
					
					
					
						
							
								
								
							
						
					
				
				
				
				
					
						
					
				
			
		
	



你可能感兴趣的:(flex学习笔记-布局)