嘿,据我所知,没有简单的设置可以防止这种情况发生。您需要做的就是在每次移动时观察它,并确保它保持在一定范围内。然后,您可以根据需要将该事件处理程序抽象为某个 Controller 类。
这是一个基本示例:
<?xml version="1.0" encoding="utf-8"?>
<s:Application
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="creationCompleteHandler()">
<fx:Script>
<![CDATA[
import flash.geom.Rectangle;
import mx.core.FlexGlobals;
import mx.core.UIComponent;
import mx.events.MoveEvent;
import mx.managers.PopUpManager;
import spark.components.TitleWindow;
protected function creationCompleteHandler():void
{
var window:TitleWindow = new TitleWindow();
PopUpManager.addPopUp(window, this, false);
PopUpManager.centerPopUp(window);
window.addEventListener(MoveEvent.MOVE, window_moveHandler);
}
protected function window_moveHandler(event:MoveEvent):void
{
var window:UIComponent = event.currentTarget as UIComponent;
var application:UIComponent = FlexGlobals.topLevelApplication as UIComponent;
var bounds:Rectangle = new Rectangle(0, 0, application.width, application.height);
var windowBounds:Rectangle = window.getBounds(application);
var x:Number;
var y:Number;
if (windowBounds.left <= bounds.left)
x = bounds.left;
else if (windowBounds.right >= bounds.right)
x = bounds.right - window.width;
else
x = window.x;
if (windowBounds.top <= bounds.top)
y = bounds.top;
else if (windowBounds.bottom >= bounds.bottom)
y = bounds.bottom - window.height;
else
y = window.y;
window.move(x, y);
}
]]>
</fx:Script>
</s:Application>
希望有帮助,兰斯