3 Replies Latest reply on Aug 3, 2007 3:42 PM by ntsiii

    View Stacks or States?

    Gregory_Pierce Level 1
      So I have this interface where someone logs into a system and they go to a dashboard. That's part is cool. But then I have the option of then using a view stack to allow people to navigate the different menu options/tabs or I could use states to accomplish the same thing. It isn't entirely clear to me which way I should go when I'm building out the interface.

      When should I choose one over the other?
        • 1. Re: View Stacks or States?
          Level 7
          Gregory Pierce wrote:
          > So I have this interface where someone logs into a system and they go to a
          > dashboard. That's part is cool. But then I have the option of then using a view
          > stack to allow people to navigate the different menu options/tabs or I could
          > use states to accomplish the same thing. It isn't entirely clear to me which
          > way I should go when I'm building out the interface.
          >
          > When should I choose one over the other?
          >

          In my limited experience I base it on the amount of change between one
          view to another. In my first live application I have a two element view
          stack and two view states. The view states are used to add/remove a
          single control from the user interface. The view stack is used to
          completely change every element of the view from one 'page' to the next.
          For a small application with only four main UI views it works nicely.

          Let me know if you would like more details.

          <mx:states>
          <mx:State name="comment">
          <mx:AddChild position="lastChild">
          <Ctrl:comment
          id="commentDialog"
          saveCommentEvent="saveCommentEventHandler(event)"
          cancelDialogEvent="cancelCommentEventHanderl(event)"
          commentType="{commentType}"
          horizontalCenter="0" top="50"/>
          </mx:AddChild>
          </mx:State>

          <mx:State name="login">
          <mx:AddChild position="lastChild">
          <mx:Container
          top="0" left="0"
          width="100%" height="100%"
          backgroundColor="#000022"
          backgroundAlpha=".85"/>
          </mx:AddChild>

          <mx:AddChild position="lastChild">
          <Ctrl:loginForm
          id="loginForm"
          horizontalCenter="0"
          top="100"
          loginSubmitEvent="loginCheck(event)"/>
          </mx:AddChild>
          </mx:State>
          </mx:states>

          ...

          <mx:ViewStack id="troubleLog"
          width="100%" height="100%"
          minWidth="0" minHeight="0">

          <views:masterList x="0" y="0" id="master"
          gridSource="{troubleLogAry}"
          loadTroubleEvent="readTroubleEvent(event)"
          newTroubleEvent="initTroubleEvent()"
          selectTroubleLogView="viewDetails(1)"
          filterUpdateEvent="updateFilterHandler(event)"/>

          <views:logDetails x="0" y="0" id="details"
          colorsAry="{colorsAry}"
          troubleLogEntry="{troubleLogEntry}"
          assigneesAry="{assigneesAry}"
          applicationsAry="{applicationsAry}"
          saveTroubleEvent="saveTroubleEvent(event)"
          selectTroubleLogView="viewDetails(0)"
          showCommentDialogEvent="displayCommentHandler(event)"/>
          </mx:ViewStack>
          • 2. Re: View Stacks or States?
            jfillman Level 1
            I don't know that there is a right or wrong answer to this. When it comes to lines of code, the tabs might be a better option. If you are basing subsequent states on a base state, then you have to remove and add each item individually, adding a lot of code and making it a bit harder to ready. Personally, I don't care for tabs as a way of navigation in my application.
            • 3. Re: View Stacks or States?
              ntsiii Level 3
              "...base it on the amount of change between one view to another...". This is also my criteria. Although I still use Viewstack predominantly, because it is so simple. States are comparatively complicated.

              Tracy