0

我已经实现了一种更改显示大小的方法。

当我单击最大化时,我会重新定位视图堆栈中的一些按钮。问题是当我恢复视图时按钮消失了。

有人能帮我吗?

{       
    nativeWindow.addEventListener(NativeWindowBoundsEvent.RESIZING, onAppResize);

    nativeWindow.addEventListener(NativeWindowBoundsEvent.RESIZE, onAppResize);

    nativeWindow.addEventListener(NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGING,onAppMaximized);

    var screenBounds:Rectangle = Screen.mainScreen.bounds;
    nativeWindow.x = 10;
    nativeWindow.y = 10;    
}

private function onAppMaximized(e:NativeWindowDisplayStateEvent):void
{

    if(String(e.afterDisplayState) == "maximized" && DisplayMaximized == false)
    {
        e.preventDefault();

        nativeWindow.x = 10;
        nativeWindow.y = 10;

        AppImageWidth = 1280;
        AppImageHeight = 900;

        nativeWindow.width = 1280;
        nativeWindow.height = 900;

        viewstack.createComponentsFromDescriptors(true);

        viewstackBuchungen.width = 1206;
        viewstackBuchungen.height = 600;

        Button.x = 1135;
        Button.y = 608;

        Button2.x = 1135;
        Button2.y = 608;

        DisplayMaximized = true;
    }
    else if(String(e.afterDisplayState) == "maximized" && DisplayMaximized == true)
    {
        e.preventDefault();

        AppImageWidth = 1024;
        AppImageHeight = 600;

        nativeWindow.width = 1024;
        nativeWindow.height = 600;

        viewstackBuchungen.width = 950;
        viewstackBuchungen.height = 313;

        Button.x = 879;
        Button.y = 321;

        Button2.x = 879;
        Button2.y = 321;

        DisplayMaximized = false;
    }
}
4

1 回答 1

0

感谢您的回答。我尝试使用 .move(x,y) 移动它们。没有改变...

这些按钮位于相同的位置,因为它们位于不同的导航器内容中。

<
s:WindowedApplication 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="init();" 宽度=“1024”高度=“600”>
        private function init():void
        {
            nativeWindow.addEventListener(NativeWindowBoundsEvent.RESIZING, onAppResize);
            nativeWindow.addEventListener(NativeWindowBoundsEvent.RESIZE, onAppResize);

            nativeWindow.addEventListener(NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGING,onAppMaximized);
            nativeWindow.x = 10;
            nativeWindow.y = 10;
        }
        private function onAppResize(e:NativeWindowBoundsEvent):void
        {
            e.preventDefault();
        }
        private function onAppMaximized(e:NativeWindowDisplayStateEvent):void
        {
            if(String(e.afterDisplayState) == "maximized" && DisplayMaximized == false)
            {
                e.preventDefault();

                nativeWindow.x = 10;
                nativeWindow.y = 10;

                nativeWindow.width = 1280;
                nativeWindow.height = 900;

                viewstack1.createComponentsFromDescriptors(true);

                viewstack1.width = 1206;
                viewstack1.height = 600;

                button1.move(1135,608);

                button2.move(1135,608);

                DD1.move(1082,608);

                DisplayMaximized = true;
            }
            else if(String(e.afterDisplayState) == "maximized" && DisplayMaximized == true)
            {
                e.preventDefault();

                nativeWindow.width = 1024;
                nativeWindow.height = 600;

                viewstack1.width = 950;
                viewstack1.height = 313;


                button1.move(879,321);

                button2.move(879,321);

                DD1.move(826,321);

                DisplayMaximized = false;
            }
        }
    ]]>
</fx:Script>
<fx:Declarations>
    <!-- Platzieren Sie nichtvisuelle Elemente (z. B. Dienste, Wertobjekte) hier -->
</fx:Declarations>

<s:Group x="16" y="113" width="1254" height="463">
    <mx:ViewStack id="viewstack1" x="0" y="24" width="950" height="313" selectedIndex="0" creationPolicy="all">
        <s:NavigatorContent width="100%" height="100%" label="Nav1" id="nav1" creationPolicy="all">
            <mx:AdvancedDataGrid id="grid1" x="0" y="0" width="100%" height="100%"
                                 designViewDataType="flat"
                                 editable="true" horizontalScrollPolicy="off"
                                 sortableColumns="false" resizableColumns="false" draggableColumns="false">
                <mx:columns>
                    <mx:AdvancedDataGridColumn dataField="test1" headerText="test1" width="35"/>
                </mx:columns>
            </mx:AdvancedDataGrid>
            <s:Button x="879" y="321" label="Button1" id="button1"/>
        </s:NavigatorContent>
        <s:NavigatorContent width="100%" height="100%" label="Nav2" id="nav2" creationPolicy="all">
            <mx:AdvancedDataGrid id="grid2" x="0" y="0" width="100%" height="100%"
                                 designViewDataType="flat"
                                 editable="true" horizontalScrollPolicy="off"
                                 sortableColumns="false" resizableColumns="false" draggableColumns="false">
                <mx:columns>
                    <mx:AdvancedDataGridColumn dataField="test2" headerText="test2" width="35"/>
                </mx:columns>
            </mx:AdvancedDataGrid>
            <s:Button x="879" y="321" label="Button2" id="button2" />
        </s:NavigatorContent>
        <s:NavigatorContent width="100%" height="100%" label="Nav3"  id="nav3" creationPolicy="all">
            <mx:AdvancedDataGrid id="grid3" x="0" y="0" width="100%" height="100%"
                         designViewDataType="flat"
                         editable="true" horizontalScrollPolicy="off"
                         sortableColumns="false" resizableColumns="false" draggableColumns="false">
                <mx:columns>
                    <mx:AdvancedDataGridColumn dataField="test3" headerText="test3" width="35"/>
                </mx:columns>
            </mx:AdvancedDataGrid>
            <s:DropDownList x="826" id="DD1" y="321" width="125" prompt="DD1" alpha="1"/>
        </s:NavigatorContent>
    </mx:ViewStack>
    <s:TabBar x="0" y="0" dataProvider="{viewstack1}" />
</s:Group>

于 2012-05-18T12:43:34.953 回答