5 Replies Latest reply on Apr 8, 2010 7:14 PM by David_F57

    Flash Builder 4 States.

    SpaghettiCoder Level 3

      When you use States, is it doing more than a .visible = false/true type thing?

       

      If you have a event listener on a button from one state, and you go to another state, does that event listener stay with it, or does it dissappear, and you have to re-assign it again.  Can you assign it a new listener?

       

      Any negative/cons in terms of using States in a project?

        • 1. Re: Flash Builder 4 States.
          David_F57 Level 5

          Hi,

           

          I think the only issue people seem to have with states is item instantiation, when you have something in a state its not instantiated until its displayed. You can get past this by setting itemCreationPolicy="immediate", this way if you need to populte an object in a state that hasn't been displayed you won't get null reference errors.

           

           

          David.

          • 2. Re: Flash Builder 4 States.
            CoreyRLucier Adobe Employee

            For components that use includeIn or excludeFrom, the components don't live on the display list at all for states that don't include them.  In addition they aren't even created until a state is entered where they exist.

             

            Once created, the same instance will be consistent across all states so no need to ever re-assign a listener.

             

            You can however if so desired give them different listeners for different states.  e.g. click.StateA="foo()"  click.StateB="bar()" .

             

            -C

            • 3. Re: Flash Builder 4 States.
              david.t.lanton Level 1


              For components that use includeIn or excludeFrom, the components don't live on the display list at all for states that don't include them.  In addition they aren't even created until a state is entered where they exist.

              Corey is right. I've had a similar problem where I was hooking actionscript to a component id that didn't exist in the current/normal state. I was getting an error (I believe at runtime) that this component id doesn't exist. Had to fix it by setting it to visible=false instead.

              • 4. Re: Flash Builder 4 States.
                Ansury Level 3

                But more importantly, the OP seems to be asking a good question: what's the verdict on states in SDK 4?  Should they be used more commonly than in 2/3, or do most experienced developers still prefer to reserve states for trivial/small components (if at all)?  Will we continue to see statements like "don't use states, use ViewStack"?  Are states really practical and maintainable in their new form?

                 

                I'm still too traumatized over the 2/3 states failure to bother with trying 4's yet, although I will at some point.

                • 5. Re: Flash Builder 4 States.
                  David_F57 Level 5

                  Hi Ansury,

                   

                  I agree that states were a 'traumatic' experience in previous incarnations, so far they seem to be a better option than they used to be, as per usual we will end up with 2 parties states v. viewstacks.

                   

                  One big annoyance with states is the 'missing' allstates flag, for example when moving objects around in designview(yeah I know hard core coders have an avid dislike for DV) the IDE should have the smarts built in to know if you are changing the object for the current state or all states.

                   

                  In general I am finding that moving away from viewstacks to states on the surface seems ok but like anything only time will tell as the use grow more complex, I think that states have moved in the right direction and hopefully will evolve to a point where we don't need to hedge our bets between states/viewstack.

                   

                  David