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 をネイティブ ウィンドウ内に配置することもできるため、少し混乱します。作成が完了した後に配置を行う必要があります。そうしないと、null 参照エラーが発生します。

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;

これにより、新しいウィンドウが右上隅に配置され、上部と右側に 25 ピクセルのパディングが追加されます。

于 2010-06-24T13:56:32.603 に答える