actionscript-3apache-flexflash-builderflex4.6

Flex 4.6 SplitViewNavigator - Display / Hide Navigators


I have just started a new project and am looking to use the SplitViewNavigator layout for some of my screens as it lends itself well to what I'll be doing.

However not all of the screens should use this layout (homeview being one of them). So I started by setting the visibility of the side view as false.

<s:SplitViewNavigator includeIn="tablet" width="100%" height="100%">
    <s:layout.landscape>
        <s:HorizontalLayout />
    </s:layout.landscape>
    <s:layout.portrait>
        <s:VerticalLayout />
    </s:layout.portrait>
    <s:ViewNavigator width.landscape="35%" height.landscape="100%"
                     width.portrait="100%" height.portrait="30%"
                     firstView="views.TestView" visible="false"/>
    <s:ViewNavigator width="100%" height="100%" height.portrait="100%"
                     firstView="views.OnSiteFormHomeView" />
</s:SplitViewNavigator>

I know how to access the SpitViewNavigator and the individual ViewNavigators. So I did the following in my home view (as a test) but nothing seems to happen. (the other navigator stays full screen). I've tried attaching the code to the intialize and creationcomplete events.

// Create a reference to the SplitViewNavigator.
var splitNavigator:SplitViewNavigator = navigator.parentNavigator as SplitViewNavigator;
// Create a reference to the ViewNavigator for the Detail frame.
var sideNavigator:ViewNavigator = splitNavigator.getViewNavigatorAt(0) as ViewNavigator;
var detailNavigator:ViewNavigator = splitNavigator.getViewNavigatorAt(1) as ViewNavigator;
sideNavigator.visible = true;

I assume that I need to somehow make it redraw the screen/navigators. I've tried calling the initialize function on the splitviewnavigator and also the individual navigators but it seems to make no difference.


Solution

  • To answer my own query. I found that it works for me between views (popping/pushing) so I can just do the following (from a single view screen):

    sideNavigator.visible = true;
    sideNavigator.pushView(SideViewHere);
    detailNavigator.pushView(NewMainView);
    

    and the reverse would be:

    detailNavigator.popView();
    sideNavigator.visible = false;
    sideNavigator.popView();
    

    Which gives me everything I need.