`

Flex TitleWindow控制拖动范围

 
阅读更多
package com.s.compons
{
	import flash.events.MouseEvent;
	
	import mx.controls.Alert;
	
	import spark.components.TitleWindow;
	
	/**
	 * 控制TitleWindow拖动范围。
	 * 
	 * @author jacksang
	 */	
	public class TitleWindows extends TitleWindow
	{
		/**
		 * 窗口左右最少暴露出来的宽度 
		 */		
		private var _offlx:int = 20;
		
		private var _offrx:int = 20;
		
		
		public function TitleWindows()
		{
			super();
		}
		
		override public function move(x:Number, y:Number):void
		{
			
			//重写Move方法,控制窗口移动范围,左右暴露出来至少是offlx offrx,上面不允许拖出窗口,下面最少漏出moveArea区域
			if(x + this.width < this._offlx)
			{
				x = this._offlx - this.width  ;
			}
			
			if ( this.parent.width - x < this._offrx )
			{
				x = this.parent.width - this._offrx;
			}
			
			if(y < 0) 
			{
				y = 0;
			}
			
			
			if ( y - this.parent.height >= - this.moveArea.height )
			{
				y = this.parent.height - this.moveArea.height;
			}
			
			super.move(x,y);
		}
	}
}
0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics