Recently did the project when used in the form of Tiltewindow pop-up window, found that sometimes accidentally drag the window onto the top will not be dragged back, resulting in pop-up windows can not be closed, and later found a good solution, in the pop-up window component initialization method with the following code can be
Copy Code code as follows:
This.addeventlistener (Titlewindowboundsevent.window_move,function ( event:event): void{
Event.target.x = event.target.x < 0? 0:event.target.x;
if (event.target.x + event.target.width > Event.target.parent.width) {
if (Event.target.parent.width- Event.target.width < 0) {
Event.target.x = 0;
}else{
Event.target.x = event.target.parent.width-event.target.width;
}
}
Event.target.y = Event.target.y < 0? 0:event.target.y;
if (event.target.y + event.target.height > Event.target.parent.height) {
if (event.target.parent.height -Event.target.height < 0) {
Event.target.y = 0;
}else{
Event.target.y = event.target.parent.height-event.target.height;
}
}
});