Hi,

Thanks for the quick response.  Makes sense a bit more.  I posted a
similar question before and got good answer but still wanted to get some
additional insight.

Thanks for the help!

-Malik
--- In flexcoders@yahoogroups.com, "Shannon Hicks" <[EMAIL PROTECTED]> wrote:
>
> 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: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED]
On
> Behalf Of malik_robinson
> Sent: Tuesday, July 18, 2006 9:58 PM
> To: flexcoders@yahoogroups.com
> 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="HYPERLINK
> "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="HYPERLINK
> "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="HYPERLINK
> "http://www.adobe.com/2006/mxml"http://www.adobe.com/2006/mxml";
width="400"
> height="300">
>
>  <mx:Panel
>            xmlns:mx="HYPERLINK
> "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>
>
>
>
>
>
>
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.394 / Virus Database: 268.10.1/390 - Release Date:
7/17/2006
>
>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.1.394 / Virus Database: 268.10.1/390 - Release Date:
7/17/2006
>






------------------------ Yahoo! Groups Sponsor --------------------~--> 
Check out the new improvements in Yahoo! Groups email.
http://us.click.yahoo.com/6pRQfA/fOaOAA/yQLSAA/nhFolB/TM
--------------------------------------------------------------------~-> 

--
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

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to