新窗口/查看 mxml flex

发布于 2024-12-19 08:47:26 字数 165 浏览 2 评论 0原文

我遇到以下如何将另一个 mxml 文件显示为应用程序主视图的问题

例如,假设我将 main.mxml 显示为主窗口。当我单击按钮时,我想显示另一个 mxml 文件,例如 newMain.mxml 并关闭 main.mxml

I have the following problem of how to display another mxml file as main view of application

For example, lets say I have main.mxml displaying as main window. When I click button I want to display another mxml file lets say newMain.mxml and close main.mxml

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

离去的眼神 2024-12-26 08:47:26

是的,您可以通过使用 Adob​​e AIR 中的 NativeWindow 类来实现。

您可以创建本机窗口并可以激活它。
在将 newMain.mxml 激活到另一个本机窗口时,您可以将 main.mxml 设置为可见 false。

当关闭 newMain.mxml 时,您可以将 main.mxml 设置为可见 true。

我提供了一些示例 Flex 4.5 应用程序代码。

<?xml version="1.0" encoding="utf-8"?>
<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">
    <fx:Script>
        <![CDATA[

            private var n:NativeWindow;
            private var ni:NativeWindowInitOptions;

            protected function onBtnOpenClick(event:MouseEvent):void
            {
                ni = new NativeWindowInitOptions();
                ni.systemChrome = NativeWindowSystemChrome.STANDARD;
                ni.type = NativeWindowType.NORMAL;
                ni.transparent = false;
                ni.resizable = false;
                ni.minimizable = true;
                ni.maximizable = true;

                n = new NativeWindow(ni);
                n.title = "My Native Window";
                n.addEventListener(Event.CLOSING, onClosingWindowEvent);
                n.activate();

                nativeWindow.visible = false;
            }

            private function onClosingWindowEvent(event:Event):void
            {
                nativeWindow.visible = true;
            }
        ]]>
    </fx:Script>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>

    <s:Button x="217" y="110" label="Open" click="onBtnOpenClick(event)"/>

</s:WindowedApplication>

Yes, you can do it by using NativeWindow Class in Adobe AIR.

You can create native window and can activate it.
While activating your newMain.mxml into another native window you can set your main.mxml to visible false.

And when closing your newMain.mxml you can set main.mxml to visible true.

I am giving some sample Flex 4.5 Application Code.

<?xml version="1.0" encoding="utf-8"?>
<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">
    <fx:Script>
        <![CDATA[

            private var n:NativeWindow;
            private var ni:NativeWindowInitOptions;

            protected function onBtnOpenClick(event:MouseEvent):void
            {
                ni = new NativeWindowInitOptions();
                ni.systemChrome = NativeWindowSystemChrome.STANDARD;
                ni.type = NativeWindowType.NORMAL;
                ni.transparent = false;
                ni.resizable = false;
                ni.minimizable = true;
                ni.maximizable = true;

                n = new NativeWindow(ni);
                n.title = "My Native Window";
                n.addEventListener(Event.CLOSING, onClosingWindowEvent);
                n.activate();

                nativeWindow.visible = false;
            }

            private function onClosingWindowEvent(event:Event):void
            {
                nativeWindow.visible = true;
            }
        ]]>
    </fx:Script>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>

    <s:Button x="217" y="110" label="Open" click="onBtnOpenClick(event)"/>

</s:WindowedApplication>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文