TitleWindow放大放小还原关闭拖拽放大窗体


ReSizeTitleWinAs.as

package eko.containers
{
import flash.display.DisplayObject;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.geom.Point;

import mx.containers.TitleWindow;
import mx.controls.Button;
import mx.core.Application;
import mx.core.FlexGlobals;
import mx.managers.CursorManager;
import mx.managers.PopUpManager;

public class ReSizeTitleWinAs extends TitleWindow
{
// [Event(name="myClose")]
// [Event(name="myMax")]
// [Event(name="myMin")]
// [Event(name="myRestore")]

private var btnClose:Button;//关闭按钮
private var btnMin:Button;//最小化按钮
private var btnMax:Button;//最大化按钮
private var btnRestore:Button;//还原按钮
private var theStatus:int=0;//窗口状态,0正常 1最大化 2最小化;
private var isReSize:Boolean;//是否允许缩放
private var theMinWidth:Number=200;//窗口最小宽度
private var theMinHeight:Number=200;//窗口最大高度
private var theOldPoint:Point;//改变大小前窗口的x,y坐标
private var theOldWidth:Number;//最大最小化时的宽
private var theOldHeight:Number;//最大最小化时的高

//初始化窗体宽,高,x,y
private var initWidth:Number;
private var initHeight:Number;
private var initX:Number;
private var initY:Number;

private var mouseMargin:Number=4;//拖动时候响应范围

//设置光标的位置值 右上:3 右下:6 左下:11 左上8
private var theSide:Number=0;
private var SIDE_OTHER:Number=0;
private var SIDE_TOP:Number=1;
private var SIDE_RIGHT:Number=2;
private var SIDE_LEFT:Number=7;
private var SIDE_BOTTOM:Number=4;

//当前鼠标光标类
public var currentType:Class=null;
//按钮图标
[Embed("/assets/images/Buttonclose.png")]
private var IconClose:Class;
[Embed("/assets/images/Buttonmaximize.png")]
private var IconMax:Class;
[Embed("/assets/images/Buttonminimize.png")]
private var IconMin:Class;
[Embed("/assets/images/Buttonrestore.png")]
private var IconRestore:Class;

//鼠标光标图标
[Embed("/assets/images/resizeCursorH.gif")]
private var CursorH:Class;
[Embed("/assets/images/resizeCursorTLBR.gif")]
private var CursorR:Class;
[Embed("/assets/images/resizeCursorTRBL.gif")]
private var CursorL:Class;
[Embed("/assets/images/resizeCursorV.gif")]
private var CursorV:Class;
private var CursorNull:Class=null;

public function ReSizeTitleWinAs()
{
super();
}

/**
* override 重载TitleWindow的createChildren方法
* Title添加放大,放小,还原,关闭按钮
* 添加按钮监听事件
* 设置按钮样式图片
* 添加窗体拖动监听事件
*
*/
protected override function createChildren():void
{
super.createChildren();
btnClose=new Button();//关闭按钮
btnMin=new Button();//最小化按钮
btnMax=new Button();//最大化按钮
btnRestore=new Button();//还原按钮
//设置按钮的样式
btnClose.setStyle("upIcon",IconClose);
btnMin.setStyle("upIcon",IconMin);
btnMax.setStyle("upIcon",IconMax);
btnRestore.setStyle("upIcon",IconRestore);
btnClose.setStyle("downIcon",IconClose);
btnMin.setStyle("downIcon",IconMin);
btnMax.setStyle("downIcon",IconMax);
btnRestore.setStyle("downIcon",IconRestore);
btnClose.setStyle("overIcon",IconClose);
btnMin.setStyle("overIcon",IconMin);
btnMax.setStyle("overIcon",IconMax);
btnRestore.setStyle("overIcon",IconRestore);
//加载按钮
rawChildren.addChild(btnClose);
rawChildren.addChild(btnMin);
rawChildren.addChild(btnMax);
rawChildren.addChild(btnRestore);
//监听按钮事件
btnClose.addEventListener(MouseEvent.CLICK,onCloseClick);
btnMin.addEventListener(MouseEvent.CLICK,onMinClick);
btnMax.addEventListener(MouseEvent.CLICK,onMaxClick);
btnRestore.addEventListener(MouseEvent.CLICK,onReClick);
btnRestore.visible=false;
//侦听拖拽相关的事件
this.addEventListener(MouseEvent.MOUSE_MOVE,onMouseMove);
this.addEventListener(MouseEvent.MOUSE_OUT,onMouseOut);
this.addEventListener(MouseEvent.MOUSE_DOWN,onMouseDown);

//记录初始化时候的窗体信息
initWidth=this.width;
initHeight=this.height;
initX=this.x;
initY=this.y;
}

/**
* 通过设置此容器子项的位置和大小来响应大小更改。
* 定义添加按钮的位置,大小
* @param unscaledWidth:Number
* @param unscaledHeight:Number
*
*/
protected override function updateDisplayList(unscaledWidth:Number,unscaledHeight:Number):void
{
//按钮布局
super.updateDisplayList(unscaledWidth,unscaledHeight);
var AssetClose:DisplayObject=btnClose.getChildByName("upIcon");
var AssetWidth:int=AssetClose.width+5;
var AssetHeight:int=AssetClose.height+5;
//设置按钮样式
btnClose.setActualSize(AssetWidth,AssetHeight);
btnMin.setActualSize(AssetWidth,AssetHeight);
btnMax.setActualSize(AssetWidth,AssetHeight);
btnRestore.setActualSize(AssetWidth,AssetHeight);
var fromTop:int=10;
var fromRight:int=10;
var theX:int=unscaledWidth-AssetWidth-fromRight;
var theY:int=fromTop;
btnClose.move(theX,theY);
btnMax.move(theX-18,theY);
btnMin.move(theX-34,theY);
btnRestore.move(theX-18,theY);
}
/**
* 窗体关闭事件
* @param event:MouseEvent
*
*/
private function onCloseClick(event:MouseEvent):void
{
btnMax.visible=true;
btnRestore.visible=false;
PopUpManager.removePopUp(this);
theStatus=0;
// this.dispatchEvent(new Event("myClose"));
}
/**
* 窗体缩小事件
* @param event:MouseEvent
*
*/
private function onMinClick(event:MouseEvent):void
{
onSaveRestore();

this.x=0;
this.y=0;
this.width=250;
this.height=50;
// this.dispatchEvent(new Event("myMin"));
theStatus=2;
}
/**
* 窗体放大事件
* @param event:MouseEvent
*
*/
private function onMaxClick(event:MouseEvent):void
{
onSaveRestore();
// this.dispatchEvent(new Event("myMax"));
this.width=stage.stageWidth;
this.height=stage.stageHeight-20;
this.x=0;
this.y=0;

this.isPopUp=false;
btnMax.visible=false;
btnRestore.visible=true;
theStatus=1;
}
/**
* 窗体还原事件
* @param event:MouseEvent
*
*/
private function onReClick(event:MouseEvent):void
{
onGetRestore();
// this.dispatchEvent(new Event("myRestore"));
//还原按钮代码
this.width=initWidth;
this.height=initHeight;
this.x=initX;
this.y=initY;

this.isPopUp=true;
btnMax.visible=true;
btnRestore.visible=false;
theStatus=0;
}
/**
* 当鼠标拖放完毕时候移除拖大窗体事件
* @param event:MouseEvent
*
*/
private function onMouseUp(event:MouseEvent):void
{
if(isReSize)
{
FlexGlobals.topLevelApplication.parent.removeEventListener(MouseEvent.MOUSE_UP,onMouseUp);
FlexGlobals.topLevelApplication.parent.removeEventListener(MouseEvent.MOUSE_MOVE,onResize);
isReSize=false;
}
//改变鼠标为指针鼠标图标
onChangeCursor(CursorNull);
}
/**
* 当鼠标按下的时候添加拖动窗口大小事件
* @param event:MouseEvent
*
*/
private function onMouseDown(event:MouseEvent):void
{
if(theSide!=0)
{
isReSize=true;
FlexGlobals.topLevelApplication.parent.addEventListener(MouseEvent.MOUSE_UP,onMouseUp);
FlexGlobals.topLevelApplication.parent.addEventListener(MouseEvent.MOUSE_MOVE,onResize);

//记录窗体位置
var point:Point=new Point();
point=this.localToContent(point);
theOldPoint=point;
}
}
/**
* 鼠标拖动重置窗口位置大小
* @param event:MouseEvent
*
*/
private function onResize(event:MouseEvent):void
{
if(isReSize)
{
//获取拖动后最终位置
var xPlus:Number=FlexGlobals.topLevelApplication.parent.mouseX-this.x;
var yPlus:Number=FlexGlobals.topLevelApplication.parent.mouseY-this.y;
//根据不同的角度的拖动改变窗体大小
switch(theSide)
{
case SIDE_RIGHT+SIDE_BOTTOM:
this.width=xPlus>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.parent.mouseX:this.x;
this.y=this.height>theMinHeight?FlexGlobals.topLevelApplication.parent.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.parent.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.parent.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.parent.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.parent.mouseY:this.y;
break;
}
}

}
/**
* 当鼠标移动到窗体外边,设置鼠标图标还原 指针图标
* @param event:MouseEvent
*
*/
private function onMouseOut(event:MouseEvent):void
{
if(!isReSize&&this.theStatus==0)
{
theSide=0;
onChangeCursor(CursorNull);
this.isPopUp=true;
}
}
/**
* 根据鼠标的拖动判断鼠标拖动方向和拖动后窗体的大小
* @param event:MouseEvent
*
*/
private function onMouseMove(event:MouseEvent):void
{
if(!theStatus)
{
var point:Point=new Point();
point=this.localToGlobal(point);
var xPosition:Number=FlexGlobals.topLevelApplication.parent.mouseX;
var yPosition:Number=FlexGlobals.topLevelApplication.parent.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,-1,-1);
theSide=SIDE_RIGHT;
this.isPopUp=false;
}else if(xPosition<(point.x+mouseMargin))
{//左
onChangeCursor(CursorH,-1,-1);
theSide=SIDE_LEFT;
this.isPopUp=false;
}else if(yPosition<(point.y+mouseMargin))
{//上
onChangeCursor(CursorV,-1,-1);
theSide=SIDE_TOP;
this.isPopUp=false;
}
else if(yPosition>(point.y+this.height-mouseMargin))
{//下
onChangeCursor(CursorV,-1,-1);
theSide=SIDE_BOTTOM;
this.isPopUp=false;
}
else
{
onChangeCursor(CursorNull);
if(!isReSize&&theStatus==0)
{
theSide=0;
this.isPopUp=true;
}
}
//拖动的时候即使改变窗体大小
event.updateAfterEvent();

//记录拖动后窗体的信息
initWidth=this.width;
initHeight=this.height;
initX=this.x;
initY=this.y;
}
}

/**
* 创建新光标并为此光标设置可选优先级。向光标列表添加新的光标。
* cursorClass 要显示的光标的类。
* priority 用于指定光标优先级的整数。
* xOffset 用于指定光标随鼠标指针变化的 x 偏移(以像素为单位)的数字。
* yOffset 用于指定光标随鼠标指针变化的 y 偏移(以像素为单位)的数字。
* @param type:Class
* @param xOffset:Number
* @param yOffset:Number
*
*/
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;
}
}
}

CustomTitleWindowAs.mxml

<?xml version="1.0" encoding="utf-8"?>
<containers:ReSizeTitleWinAs xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:containers="eko.containers.*"
layout="absolute" width="400" height="300">
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
</containers:ReSizeTitleWinAs>

 












  










  










  










  










  










  




 
 
this.y=this.height>theMinHeight?FlexGlobals.topLevelApplication.parent.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.parent.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.parent.mouseY:this.y; break; } }  } /** 
* 当鼠标移动到窗体外边,设置鼠标图标还原 指针图标 * @param event:MouseEvent *  */ 
private function onMouseOut(event:MouseEvent):void { 
if(!isReSize&&this.theStatus==0) { 
theSide=0; 
onChangeCursor(CursorNull); this.isPopUp=true; } } /** 
* 根据鼠标的拖动判断鼠标拖动方向和拖动后窗体的大小 * @param event:MouseEvent *  */ 
private function onMouseMove(event:MouseEvent):void 






  




 
 

if(!theStatus) { 
var point:Point=new Point(); 
point=this.localToGlobal(point); 
var xPosition:Number=FlexGlobals.topLevelApplication.parent.mouseX; var yPosition:Number=FlexGlobals.topLevelApplication.parent.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,-1,-1); theSide=SIDE_RIGHT; this.isPopUp=false; 
}else if(xPosition<(point.x+mouseMargin)) {//左 
onChangeCursor(CursorH,-1,-1); theSide=SIDE_LEFT; 






  




 
 
this.isPopUp=false; 
}else if(yPosition<(point.y+mouseMargin)) {//上 
onChangeCursor(CursorV,-1,-1); theSide=SIDE_TOP; this.isPopUp=false; } 
else if(yPosition>(point.y+this.height-mouseMargin)) {//下 
onChangeCursor(CursorV,-1,-1); theSide=SIDE_BOTTOM; this.isPopUp=false; } else { 
onChangeCursor(CursorNull); if(!isReSize&&theStatus==0) { 
theSide=0; 
this.isPopUp=true; } } 
//拖动的时候即使改变窗体大小 event.updateAfterEvent();  
//记录拖动后窗体的信息 initWidth=this.width; initHeight=this.height; initX=this.x; initY=this.y; } }  /** 
* 创建新光标并为此光标设置可选优先级。向光标列表添加新的光标。 * cursorClass 要显示的光标的类。 
* priority 用于指定光标优先级的整数。 
* xOffset 用于指定光标随鼠标指针变化的 x 偏移(以像素为单位)的数字。 * yOffset 用于指定光标随鼠标指针变化的 y 偏移(以像素为单位)的数字。 * @param type:Class 
* @param xOffset:Number * @param yOffset:Number *  */ 






  




 
 
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; } } } 
CustomTitleWindowAs.mxml  
<?xml version="1.0" encoding="utf-8"?> 
<containers:ReSizeTitleWinAs xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"  






  




 
 
xmlns:mx="library://ns.adobe.com/flex/mx"  xmlns:containers="eko.containers.*"  
layout="absolute" width="400" height="300"> <fx:Declarations> 
<!-- 将非可视元素(例如服务、值对象)放在此处 --> </fx:Declarations> 
</containers:ReSizeTitleWinAs>




  










  










  










  










  










  




 
 
this.y=this.height>theMinHeight?FlexGlobals.topLevelApplication.parent.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.parent.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.parent.mouseY:this.y; break; } }  } /** 
* 当鼠标移动到窗体外边,设置鼠标图标还原 指针图标 * @param event:MouseEvent *  */ 
private function onMouseOut(event:MouseEvent):void { 
if(!isReSize&&this.theStatus==0) { 
theSide=0; 
onChangeCursor(CursorNull); this.isPopUp=true; } } /** 
* 根据鼠标的拖动判断鼠标拖动方向和拖动后窗体的大小 * @param event:MouseEvent *  */ 
private function onMouseMove(event:MouseEvent):void 






  




 
 

if(!theStatus) { 
var point:Point=new Point(); 
point=this.localToGlobal(point); 
var xPosition:Number=FlexGlobals.topLevelApplication.parent.mouseX; var yPosition:Number=FlexGlobals.topLevelApplication.parent.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,-1,-1); theSide=SIDE_RIGHT; this.isPopUp=false; 
}else if(xPosition<(point.x+mouseMargin)) {//左 
onChangeCursor(CursorH,-1,-1); theSide=SIDE_LEFT; 






  




 
 
this.isPopUp=false; 
}else if(yPosition<(point.y+mouseMargin)) {//上 
onChangeCursor(CursorV,-1,-1); theSide=SIDE_TOP; this.isPopUp=false; } 
else if(yPosition>(point.y+this.height-mouseMargin)) {//下 
onChangeCursor(CursorV,-1,-1); theSide=SIDE_BOTTOM; this.isPopUp=false; } else { 
onChangeCursor(CursorNull); if(!isReSize&&theStatus==0) { 
theSide=0; 
this.isPopUp=true; } } 
//拖动的时候即使改变窗体大小 event.updateAfterEvent();  
//记录拖动后窗体的信息 initWidth=this.width; initHeight=this.height; initX=this.x; initY=this.y; } }  /** 
* 创建新光标并为此光标设置可选优先级。向光标列表添加新的光标。 * cursorClass 要显示的光标的类。 
* priority 用于指定光标优先级的整数。 
* xOffset 用于指定光标随鼠标指针变化的 x 偏移(以像素为单位)的数字。 * yOffset 用于指定光标随鼠标指针变化的 y 偏移(以像素为单位)的数字。 * @param type:Class 
* @param xOffset:Number * @param yOffset:Number *  */ 






  




 
 
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; } } } 
CustomTitleWindowAs.mxml  
<?xml version="1.0" encoding="utf-8"?> 
<containers:ReSizeTitleWinAs xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"  






  




 
 
xmlns:mx="library://ns.adobe.com/flex/mx"  xmlns:containers="eko.containers.*"  
layout="absolute" width="400" height="300"> <fx:Declarations> 
<!-- 将非可视元素(例如服务、值对象)放在此处 --> </fx:Declarations> 
</containers:ReSizeTitleWinAs>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值