您的位置:首页 > 其它

flex4 控制弹出窗口的拖动范围

2013-08-14 18:45 309 查看
不让其超出系统边界,侦听其move事件,不用改写组件。

代码:

var newWin:spark.components.TitleWindow=win as spark.components.TitleWindow;
newWin.addEventListener(MoveEvent.MOVE,moveRhandler);
PopUpManager.addPopUp(newWin ,this,false);
PopUpManager.centerPopUp(newWin );

}

private function moveRhandler(event:MoveEvent):void
{
var dx:Number=(event.currentTarget as spark.components.TitleWindow).x;
var dy:Number=(event.currentTarget as spark.components.TitleWindow).y;
var comp:spark.components.TitleWindow=event.currentTarget as spark.components.TitleWindow;
if(dx<0)
comp.x=0;
if(dx>FlexGlobals.topLevelApplication.width-comp.width)
comp.x=FlexGlobals.topLevelApplication.width-comp.width;
if(dy<0)
comp.y=0;
if(dy>FlexGlobals.topLevelApplication.height-comp.height)
comp.y=FlexGlobals.topLevelApplication.height-comp.height;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: