0

我正在 Flex 4 中构建一个空中应用程序。我正在创建窗口,因为我需要它们在无铬应用程序中。

这是我在主应用程序创建中完成的内容

protected function creationCompleteHandler(event:FlexEvent):void
            {

                facade.sendNotification(AppFacade.APP_INIT, this);
                var buttons:NavigatorWindow = new NavigatorWindow();
                var workingSets:WorkingSets = new WorkingSets();
                buttons.addElement( workingSets );
                buttons.width = 115;
                buttons.height =200;
                buttons.maximizable = false;
                buttons.resizable = false;

                buttons.addEventListener(AIREvent.WINDOW_COMPLETE, onWindowComplete);
                buttons.open();


            }

            private function onWindowComplete(event:AIREvent):void
            {
                event.currentTarget.x = 100;
                event.currentTarget.y = 100;
            }

由于某种原因,应用程序在屏幕中间添加了窗口,如果我设置了窗口的 x 和 y,它不会将它放在我期望的屏幕左上角的位置。窗口打开时如何定位我想要的位置?

谢谢,

4

1 回答 1

1

spark.components.Window 存在于 NativeWindow 中,如果你想在屏幕上移动它,你需要定位 NativeWindow。这有点令人困惑,因为您也可以将 Window 定位在本机窗口内。创建完成后必须进行定位,否则会出现空引用错误。

如果您基于 spark.components.Window 创建了一个组件,您可以像这样调用窗口:

var win:MyWindow = new MyWindow();  //MXML component
win.height = 150;
win.width = 300;
win.systemChrome = NativeWindowSystemChrome.NONE;
win.type = NativeWindowType.LIGHTWEIGHT;
win.showStatusBar = false;
win.transparent = true;
win.alwaysInFront = true;
win.open(true);

然后在那个 mxml 组件中,设置一个 creationComplete 事件处理程序来执行此操作:

var padding:int = 25;
this.nativeWindow.x = Screen.mainScreen.visibleBounds.right - this.width - padding;
this.nativeWindow.y = Screen.mainScreen.visibleBounds.top + padding;

这应该将您的新窗口放在右上角,顶部和右侧有 25px 的填充。

于 2010-06-24T13:56:32.603 回答