|
You need to have LoginPanel.mxml fire off an event, then
have Main.mxml capture the event, and change the state as the event
result.
Add this code to LoginPanel.mxml:
<mx:Metadata>
[Event(name="loggedin",type="flash.events.event")]
</mx:Metadata>
Then change this:
<mx:Button
label="Login" click="dispatchEvent(new
Event(loggedin))"/>
In Main.mxml, add:
<mx:Script>
<![CDATA[
public function
loginComplete():void {
currentState="home";
}
]]>
</mx:Script>
And change this:
<view:LoginPanel
id="login" loggedin="loginComplete()" />
Now, this code obviously isn't tested, but it should send
you down the right path :)
Shan From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of malik_robinson Sent: Tuesday, July 18, 2006 9:58 PM To: [email protected] Subject: [Junk E-Mail - MED] [flexcoders] Problem with States and switching to a given state.
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" layout="absolute" horizontalScrollPolicy="off" <view:LoginPanel id="login" /> </mx:Application> Home.mxml <?xml version="1.0" encoding="utf-8"?> <mx:HBox y="50" x="20"> </mx:HBox> <?xml version="1.0" encoding="utf-8"?> <mx:Panel <mx:FormItem label="Password:
"> </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
-- |
- RE: [Junk E-Mail - MED] [flexcoders] Problem with States an... Shannon Hicks
- Re: [Junk E-Mail - MED] [flexcoders] Problem with Stat... malik_robinson
- Re: [Junk E-Mail - MED] [flexcoders] Problem with Stat... malik_robinson

