Hi Dominick,
you are right, we could have used view states. But we
decided to use a ViewStack because our intend was that the login component
switches to a very different "application" component after logging in. Basically
when using view states in here you would have to remove and
then add completly different components. For us this was the exact
definition of a ViewStack. I would think of using states in view components that
change it's state based on a base state.
However, this is how it would look like using states. The
concept of changing a state in your model, and other views bind to that
state property stays the same.
<mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml"
xmlns:business="org.nevis.cairngorm.samples.login.business.*"
xmlns:control="org.nevis.cairngorm.samples.login.control.*"
xmlns:view="org.nevis.cairngorm.samples.login.view.*"
pageTitle="Cairngorm Login Sample Application"
marginTop="5" marginBottom="5"
marginLeft="5" marginRight="5"
horizontalAlign="center"
currentState="{ getState( model.workflowState ) }" >
<mx:states>
<mx:State name="loggedIn">
<mx:AddChild position="lastChild">
<mx:Label text="{'Logged in ' + model.loginDate}" id="label1"/>
</mx:AddChild>
<mx:AddChild position="lastChild">
<mx:Button label="Back">
<mx:click>model.workflowState = ModelLocator.VIEWING_LOGIN_SCREEN;</mx:click>
</mx:Button>
</mx:AddChild>
<mx:RemoveChild child="{login}"/>
</mx:State>
</mx:states>
<mx:Script>
<![CDATA[
import mx.core.UIComponent;
import org.nevis.cairngorm.samples.login.model.ModelLocator;
//-------------------------------------------------------------------------
xmlns:business="org.nevis.cairngorm.samples.login.business.*"
xmlns:control="org.nevis.cairngorm.samples.login.control.*"
xmlns:view="org.nevis.cairngorm.samples.login.view.*"
pageTitle="Cairngorm Login Sample Application"
marginTop="5" marginBottom="5"
marginLeft="5" marginRight="5"
horizontalAlign="center"
currentState="{ getState( model.workflowState ) }" >
<mx:states>
<mx:State name="loggedIn">
<mx:AddChild position="lastChild">
<mx:Label text="{'Logged in ' + model.loginDate}" id="label1"/>
</mx:AddChild>
<mx:AddChild position="lastChild">
<mx:Button label="Back">
<mx:click>model.workflowState = ModelLocator.VIEWING_LOGIN_SCREEN;</mx:click>
</mx:Button>
</mx:AddChild>
<mx:RemoveChild child="{login}"/>
</mx:State>
</mx:states>
<mx:Script>
<![CDATA[
import mx.core.UIComponent;
import org.nevis.cairngorm.samples.login.model.ModelLocator;
//-------------------------------------------------------------------------
public function getState( newState : Number ) :
String
{
if( newState == ModelLocator.VIEWING_LOGGED_IN_SCREEN )
{
return "loggedIn";
}
else
{
return "";
}
}
{
if( newState == ModelLocator.VIEWING_LOGGED_IN_SCREEN )
{
return "loggedIn";
}
else
{
return "";
}
}
[Bindable]
public var model : ModelLocator = ModelLocator.getInstance();
]]>
</mx:Script>
public var model : ModelLocator = ModelLocator.getInstance();
]]>
</mx:Script>
<!--
==========================================================================
-->
<!-- the ServiceLocator where we specify the remote services -->
<business:Services id="loginServices" />
<!-- the FrontController, containing Commands specific to this appliation -->
<control:DemoControl id="controller" />
<!-- ========================================================================== -->
<!-- the ServiceLocator where we specify the remote services -->
<business:Services id="loginServices" />
<!-- the FrontController, containing Commands specific to this appliation -->
<control:DemoControl id="controller" />
<!-- ========================================================================== -->
<view:Login
id="login" />
</mx:Application>
Best,
Alex
|
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Dominick Accattato
Sent: 08 February 2006 14:08
To: [email protected]
Subject: [flexcoders] Cairngorm2 and views
Steven and crew:
Thanks for getting us an alpha build to work with. Flex 2 is my first
opportunity to really start working with the flex framework. As a side
note, I had worked with aspatterns for a number of projects so I'm familiar with
the micro-architecture. My question is simple. The login example
uses viewstacks to change views. This works fine. However, to take
advantage of view states and transistions, shouldn't we just change states now
instead of using viewstacks? Thanks very much for all the hard work.
I look forward to the answer.
Dominick Accattato, CTO
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
SPONSORED LINKS
| Web site design development | Computer software development | Software design and development |
| Macromedia flex | Software development best practice |
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


