1 Reply Latest reply on Mar 1, 2012 9:50 AM by ProfessorC

    ViewNavigator and States (includeIn)

    ProfessorC Level 1

      I have what I believe is a fairly simple (and what I think would be a fairly common) scenario with Flash Builder 4.5. Currently just launching to the desktop for now.

       

      I've created a TabbedViewNavigatorApplication app for release on mobile.

      I have two states and four ViewNavigators in my default package, such as:

       

      <s:TabbedViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"

                                        xmlns:s="library://ns.adobe.com/flex/spark" applicationDPI="160" creationComplete="initApp()">

          <s:states>

              <s:State name="portraitState" />

              <s:State name="landscapeState"  />

          </s:states>   

          <s:ViewNavigator includeIn="portraitState,landscapeState" id="nav1" label="Tab 1" width="100%" height="100%" firstView="views.view1"/>

          <s:ViewNavigator includeIn="portraitState,landscapeState" id="nav2" label="Tab 2" width="100%" height="100%" firstView="views.view2"/>

          <s:ViewNavigator includeIn="landscapeState" id="nav3" label="Tab 3" width="100%" height="100%" firstView="views.view3"/>

          <s:ViewNavigator includeIn="landscapeState" id="nav4" label="Tab 4" width="100%" height="100%" firstView="views.view4" />

          <fx:Script>

              <![CDATA[

                  private function initApp():void{

                      // currentState="landscapeState";

                  }

       

              ]]>

          </fx:Script>

          <fx:Declarations>

              <!-- Place non-visual elements (e.g., services, value objects) here -->

          </fx:Declarations>

       

      </s:TabbedViewNavigatorApplication>

       

      (this was pretty much built completely with the project wizard for a tabbed application)

       

      My problem is that the states aren't working. If you notice, I want nav3 and nav4 to only appear if the application is in the landscapeState. But if I put anything in the includeIn parameter for the ViewNavigator, the view completely disappears, no matter what state the application is set to. Are ViewNavigators not compatible with states, or with includeIn? Or am I doing something wrong?

       

      I have a toggle on the view in nav1 that supposedly sets the state. I'm not sure I'm doing that right, either, but until I can get the ViewNavigators to pay attention to the application state, that's a moot point.

       

      Can anyone offer any pointers?

      Thanks much!

      -Carl