5 Replies Latest reply on Oct 28, 2008 11:30 AM by Ansury

    View vs State

    Jim Daniel Level 1
      I've been searching for a discussion of when to use Views vs. when to use States. If there is one I haven't been able to find it, so if one does exist can I be pointed to it? If one doen't how about starting one here?

      I'd also like to know the advantages/disadvatages of both.
        • 1. Re: View vs State
          Level 7

          "Jim Daniel" <webforumsuser@macromedia.com> wrote in message
          news:ge79ct$f3u$1@forums.macromedia.com...
          > I've been searching for a discussion of when to use Views vs. when to use
          > States. If there is one I haven't been able to find it, so if one does
          > exist
          > can I be pointed to it? If one doen't how about starting one here?
          >
          > I'd also like to know the advantages/disadvatages of both.

          http://livedocs.adobe.com/flex/3/html/using_states_2.html

          near the bottom of the page


          • 2. Re: View vs State
            Jim Daniel Level 1
            Thanks, that gives me the basics of what I was asking for.

            I'd still like to have/hear a discussion of View vs States usage. It just seems to me that this is one of those areas that gets over looked.
            • 3. Re: View vs State
              Level 7

              "Jim Daniel" <webforumsuser@macromedia.com> wrote in message
              news:ge7bn8$ibs$1@forums.macromedia.com...
              > Thanks, that gives me the basics of what I was asking for.
              >
              > I'd still like to have/hear a discussion of View vs States usage. It just
              > seems to me that this is one of those areas that gets over looked.

              I think it's one of those areas that you try it a couple of times and you
              stop wondering ;-)


              • 4. Re: View vs State
                nwebb.co.uk
                I would suggest:

                State: A small change to an existing view (addition/subtraction of a few elements)
                View: Deals with a different task, or contains multiple changes.

                Use states when something small changes within your view. For example, consider a login form where the user can also select a "not registered" checkbox. Checking this would cause 1 or 2 extra boxes to appear, allowing the user to sign up. This is a small change to an existing view - a state change.

                If however your sign-up process included a lot of extra fields and preference settings I would see that as a separate view altogether.

                I don't think there is a definitive answer but that's how I decide. I've seen a few people use states when they should have used views and it can get very messy. Consider a combo box that does one thing in one state and another thing in another state ... maintenance becomes a nightmare. One useful thing about states is easy transitioning, letting the user know what's going on. This is far more difficult to do between views for a variety of reasons - see Tink's "Efflex" library which is aimed at allowing developers to do this more easily.

                • 5. View vs State
                  Ansury Level 3
                  IMO the best time to use states is never, but I'm sure some opinions differ. By the way, I believe the syntax will probably change radically in Flex 4. (Because it's currently that bad.)