PDA

View Full Version : how to do redirecting between two pages?


hoken30
09-17-2009, 11:48 PM
Hi all,

Noob to flex 3 here trying to build a simple application. I'm not sure how to do redirecting between two pages. Basically users will start at a login page, then be sent to the Main page, if they choose to logout it should send them back to the login page and lastly, if they have a session open it should skip the login page initially.

If that made any sense, what would you suggest is the best approach for this? From what I understand there's really no 're-directing' in flex, it's more about views? So should I create an application with 2 views? And have ActionScript control which one gets shown? Or is there another way?

Appreciate any input :)

hoken30
09-18-2009, 12:27 AM
Also, I'm asking if this is best approach because if I were to do states, I would be dumping both Login and Main page code into one big file...doesn't feel right. Can I load Main as an application, then call a module if a login is needed? Would that work?

Peter Cowling
09-18-2009, 09:11 PM
I'm not sure how to do redirecting between two pages. Basically users will start at a login page, then be sent to the Main page, if they choose to logout it should send them back to the login page and lastly, if they have a session open it should skip the login page initially.


Two requirements:


change what's being displayed
keep login/logout state


You can use states, and/or viewStack, and a few other things for the first. A few thoughts on those choices below, but first:


Also, I'm asking if this is best approach because if I were to do states, I would be dumping both Login and Main page code into one big file...doesn't feel right. Can I load Main as an application, then call a module if a login is needed? Would that work?

Unlikely to be a module. Its not really worth using a module imo until you get to 150-175k's worth of code, which (should be!) is a fair amount.

But you can modularize your code. One component per view, imported, instantiated, and added (actionscript), or namespace'd, mxml'd into the main application.

States are rubbish in flex 3, and a lot of people using mxml use viewstack. States are better in flex 4. There are also a whole range of ways to work via actionscript - either in tandem with the flex component lifecycle or alongside/outside of it.

logged-in/out statefulness can be as simple as a single Boolean in the example described.