Hi Malik,
Here is an example how to control view state with Cairngorm2.
http://www.cflex.net/showfiledetails.cfm?ChannelID=1&Object=File&objectID=422
-TH
--- In flexcoders@yahoogroups.com, "malik_robinson" <[EMAIL PROTECTED]> wrote:
>
>
> Hi,
>
> How do you change the state from within different mxml files. My code
> is below. As of now I do not have any functions or anything written. I
> am just trying to work with the states in a simplistic manner. I have 3
> files. Main.mxml, LoginPanel.mxml, Home.mxml. I want the base state to
> be the login page when Main.mxml is run, once the user logs in, then I
> want to go to Home.mxml. Does anyone see how I can fix this given the
> code I have put together, any suggestions as well. I am trying to
> learn Cairngorm, but for now any assistance appreciated.
>
> Main.mxml
>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
> <http://www.adobe.com/2006/mxml> " layout="absolute"
> horizontalScrollPolicy="off"
> verticalScrollPolicy="off" xmlns:view="com.myHR.view.*" >
>
> <mx:states>
> <mx:State name="home">
> <mx:AddChild>
> <mx:target>
> <view:Home id="home" />
> </mx:target>
> </mx:AddChild>
> <mx:RemoveChild target="{login}" />
> </mx:State>
> </mx:states>
>
> <view:LoginPanel id="login" />
>
> </mx:Application>
>
> Home.mxml
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml
> <http://www.adobe.com/2006/mxml> " width="100%">
>
> <mx:HBox y="50" x="20">
>
> <mx:Panel id="myCompanies" height="325" title="Companies" x="26"
> y="60">
> <mx:HBox width="100%" height="100%">
> <mx:DataGrid resizableColumns="true" sortableColumns="true"
> height="100%">
> <mx:columns>
> <mx:DataGridColumn headerText="Name" dataField="col1"/>
> <mx:DataGridColumn headerText="Type" dataField="col2"/>
> <mx:DataGridColumn headerText="Level" dataField="col3"/>
> </mx:columns>
> </mx:DataGrid>
> </mx:HBox>
> </mx:Panel>
>
> </mx:HBox>
>
> </mx:Canvas>
>
> LoginPanel.mxml
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml
> <http://www.adobe.com/2006/mxml> " width="400" height="300">
>
> <mx:Panel
> xmlns:mx="http://www.adobe.com/2006/mxml
> <http://www.adobe.com/2006/mxml> "
> xmlns:view="com.myApp.view.*"
> title="Login"
> horizontalAlign="center">
>
> <mx:Form id="loginForm">
>
> <mx:FormItem label="Username: ">
> <mx:TextInput id="username"/>
> </mx:FormItem>
>
> <mx:FormItem label="Password: ">
> <mx:TextInput id="password" displayAsPassword="true"/>
> </mx:FormItem>
>
> </mx:Form>
> <!-- My Problem is here. I want to go back to the home state, but the
> actual states tags are defined in Main.mxml --->
> <mx:ControlBar horizontalAlign="right">
> <mx:Button label="Login" click="currentState='Main.home'"/>
> </mx:ControlBar>
>
> </mx:Panel>
>
> </mx:Canvas>
>
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
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.