Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: Managing view states  (Read 3170 times)
masterkrang
Newbie
*
Posts: 7


View Profile Email
« on: November 30, 2010, 11:15:05 »

I'm building a test air app in Flash 5 Professional and had a couple of questions. I wonder how you guys are dealing with the different view states? Since I'm not in Flex or Flash Builder and don't have access to the different view states, I'm wonder what is the best way to control them in the Flash / PureMVC world. My application has a few simple states that need to either show or hide at different times. It's pretty simple, only one of a few views will be showing at any time.

The way I'm thinking to do it is to have the main application, or ApplicationMediator keep track of times. These transitions won't be fired by user clicks, only will be fired based on different times during the day. After the time is reached, I plan to fire events telling what state the app is in, like ApplicationFacade.StateOne, ...StateTwo (of course naming these events a bit more in accordance with the actual view for each state). Then have each Mediator interested in an ApplicationFacade.ViewStateChange event, passing along with a note saying which state should show it self (at which point, all others would hide and possibly destroy themselves).

Would this be a good way to go about doing it? I'm interested in hearing how others are dealing with multiple view states from the PureMVC perspective.
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: December 01, 2010, 02:53:35 »

In a Flex app, I like to have the StateMachine utility control my application states and have mediators in charge of hearing about those changes and coordinating the appropriate view states. It's nice to have states in Flex, but not necessary. You can encapsulate the states of your views in your view component classes and expose methods that mediators use to trigger view state changes, and events you dispatch that tell your mediators about the view state transitions completing and the like.

There is a short introduction to the utility at http://puremvc.tv

Cheers,
-=Cliff>
Logged
masterkrang
Newbie
*
Posts: 7


View Profile Email
« Reply #2 on: December 06, 2010, 09:43:33 »

You say it's nice to have state in Flex and I think you're right. I'm sort of stuck in a situation where I need to decide whether I can learn StateMachine really fast or just implement Flex states project. What would you recommend? I can only guess I'll be back with questions aboutStateMachine...
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #3 on: December 09, 2010, 08:13:42 »

Even with a Flex states project, the StateMachine is useful as it keeps application state, not view state. With Flex the the nice thing is you have a handy way to deal with view states already. That's half the game. Combine it with the StateMachine and you've got the full monty, so to speak.

If you're only using Flash, you can still use StateMachine, you just need to implement view states yourself.

-=Cliff>
Logged
Pages: [1]
Print