This content has been marked as final. Show 3 replies
You mention "I think the way to go about this is to use states".
Are you acquainted with Flex's <mx:ViewStack>?
Flex 2 added the <mx:States> tag. Early Flex developers relied heavily on <mx:ViewStack> and still do.
If you are not familiar with <mx:ViewStack>, go to the Flex Component Explorer at the following link and navigate the tree along the left to: Visual Components > Containers > ViewStack.
<mx:ViewStack> actually is non-visual navigation container. Non-visual meaning you have to add some other UI components to enable user navigation through the stack.
Please note that it is not an either/or decision whether to use <mx:States> or <mx:ViewStack>. In my apps I almost always use both. fwiw, by default I use <mx:ViewStack>. I generally switch to <mx:States> for views where there are incremental changes. Generally I work in code view, but for working with <mx:States> I switch to design view. The names of the tags that get nested in <mx:States> pretty well highlight what "incremental changes" tend to be: SetProperty, SetStyle, RemoveChild, AddChild, etc.
Regardless whether you use <mx:States> or <mx:ViewStack> or some other navigation container please, please, please create your application as a series of custom components (vs as "monolithic" file that contains 100% of the code ;-)
btw, If you adopt an MVC microarchitecture, your application will naturally be created as a series of custom components. Popular MVC microarchitectures used with Flex include Cairngorm and PureMVC.org (among others).
Rather than my rambling on any further, I will wait for you to reply as to whether you have any questions or thoughts on the applicability to your application of <mx:States> vs <mx:ViewStack>.
If you are curious on further reading, following are a few sources:
Creating Flex Components by Bruce Eckel
For Flex 2.0 Beginners - Use the mx:States and mx:ViewStack Tags To Change The Application's View
Please post back regarding whether the above answers your question, and if you find it helpful :-)
I use 'states' mostly myself. But my primary states are "pop-in modules." Flex Modules allow the separation of content into externally loaded .swf files. This can be useful in large applications to reduce the initial load time.
Thanks for the responses and all the info. I've actually got Flex 3.0 for beginners which is turning out to be a really useful book. Your responses have reassured me that I'm on the right track.