读书人

统制titlewindow的移动范围不让超过应

发布时间: 2012-09-02 21:00:34 作者: rapoo

控制titlewindow的移动范围不让超过应用程序宽度

1.添加WINDOW_MOVE事件,snapshotTool为myTool为窗体对象

myTool.addEventListener(TitleWindowBoundsEvent.WINDOW_MOVE,myMoveHandler);

2.

?? private function myMoveHandler(event:TitleWindowBoundsEvent):void
{
?? ?var currTarget:MyTool = event.currentTarget as MyTool ;
?? ?var x:Number = currTarget.x;
?? ?var y:Number = currTarget.y;

?? ?if (y >= this.parentApplication.height - 20)
?? ?{
?? ??? ?currTarget.y=this.parentApplication.height - 20;
?? ?}

?? ?if (y <= 0)
?? ?{
?? ??? ?currTarget.y=0;
?? ?}

?? ?if (x >= this.parentApplication.width - currTarget.width)
?? ?{
?? ??? ?currTarget.x=(this.parentApplication.width - currTarget.width);
?? ?}

?? ?if (x <= 0)
?? ?{
?? ??? ?currTarget.x=0;
?? ?}
?? ?
}

读书人网 >Web前端

热点推荐