2 Replies Latest reply on Dec 12, 2010 9:08 PM by AaronCA

    Catching a state change (enterState/exitState confusion)

    AaronCA

      So I have an app with very clearly defined states, each represented by a custom component. All the main mxml file does is show the component pertaining to the current state. Each custom component can successfully dispatch a state change event. I have no problems (so far) actually changing between states. The problem is executing particular code inside of the custom component when the state changes. For example, I have a chat lobby component. Each and every time I enter that state, it needs to log in to the server. Whenever I leave that state, it needs to disconnect. I have tried enterState, exitState, hide, show, and nothing seems to work. creationComplete works for logging in, but obviously only the first time. Can somebody please help me understand how to accomplish this? I assume the problem has to do with a misunderstanding of how states and events work. Perhaps the enterState/exitState isn't working in the custom component because the actual state change is taking place in the root application. If that is so, then what can I do inside of the component to catch the entering and exiting? I realize that I could attach code to specific controls that do something specific before emitting the stateChange event, but I would really prefer a global solution if at all possible.

       

      This Flex n00b sincerely appreciates your time and assistance.

      Aaron