flexlib包 修改MDIWindow可以边界停靠


修改MDIWindow.as文件的 onWindowMove

添加两个属性 只有在 windowManager.enforceBoundaries =false时候可用

1. floatInCanvas  是否停靠  

2.floatSize   停靠边界露出部分的宽度或者高度  默认为 30px

这样 窗体就不会被拖动的不见了。


private function onWindowMove(event:Event):void
		{
			if(!_dragging)
			{
				_dragging = true;
				// clear styles (future versions may allow enforcing constraints on drag)
				this.clearStyle("top");
				this.clearStyle("right");
				this.clearStyle("bottom");
				this.clearStyle("left");
				dispatchEvent(new MDIWindowEvent(MDIWindowEvent.DRAG_START, this));
			}

			if(windowManager.enforceBoundaries)
			{
				x = Math.max( 0, Math.min( parent.width - this.width, parent.mouseX - dragStartMouseX ) );
				y = Math.max( 0, Math.min( parent.height - this.height, parent.mouseY - dragStartMouseY ) );
			}
			else
			{
				if(floatInCanvas)
				{
					//靠右
					var tmp_x:Number = Math.max( 0, Math.min( parent.width - floatSize, parent.mouseX - dragStartMouseX ) );
					
					if(tmp_x<dragStartMouseX)
					{
						//表示往左
						
						x = parent.mouseX - dragStartMouseX;
						if((x*(-1))>=this.width)
							x = this.width *(-1) + floatSize;
					}
					else{
						x=tmp_x;
					}
					
					y = Math.max( 0, Math.min( parent.height - floatSize, parent.mouseY - dragStartMouseY ) );
				}
				else
				{
					x = parent.mouseX - dragStartMouseX;
					y = parent.mouseY - dragStartMouseY;
				}
			}

			dispatchEvent(new MDIWindowEvent(MDIWindowEvent.DRAG, this));
		}


 更新后库文件下载: 下载链接



你可能感兴趣的:(flexlib包 修改MDIWindow可以边界停靠)