This content has been marked as final. Show 4 replies
no this isn't a good structure. Keeping everything in one mxml is asking the code maintainer to be "punished".
1. separate your states into "views", by creating custom components to represent each states.
2. set up a blank "home view" state. All other states you have can then use it as reference.
3. to manage states create a "model" (singleton) to handle the transition from state to state
4. create as3 files specific to each "view" and reference them in their respective mxml files.
take a look at this link:
I agree with Xilian regarding the use of the Singleton pattern. I am currently writing a large application using Cairngorm and I love it!!!
I've never been a big fan of States. More out of ignorance or lack of experience with them I suppose. So here is how I handle things. Same concept slightly different implementation. There are always many way to skin the cat so to speak.
Anywhere in my code all I have to do is get an instance of the modelLocator and set the workflowState variable to one of my views to display the appropriate data.
Also, I find ViewStack to be much easier to work with than states.
Thanks for your comments. Glad I gave this some thought and asked for advice.