MXML:不同视图的默认 MXML

MXML: Default MXML for Different Views

我有以下默认的 mxml 配置。

 <s:ViewNavigatorApplication
    xmlns:fx="http://ns.adobe.com/mxml/2009" 
    xmlns:s="library://ns.adobe.com/flex/spark" 
    firstView="Home" 
    creationComplete="init()"
>

是否可以为 firstView 设置条件值?

我正在寻找一种方法来在 3 个不同的视图中实现我的应用程序以实现移动兼容性。
所以我想为每个视图创建不同的包。有什么解决方法吗?

您可以使用 ViewNavigator 手动定义视图 - 从 MXML 中删除 firstView 并在 init() 方法中执行类似的操作:

private function init():void
{
    if(something)
    {
        navigator.pushView(Home);
    }
    else
    {
        navigator.pushView(OtherView);
    }
}

// pass myData as data to the new view (will be accessible as .data property in the Home view):
navigator.pushView(Home, myData);

// remove the last view from the viewstack:
navigator.popView();

This article 可能有帮助