Yeah you can do what rohit said by adding a logout button at the same place and 
toggling the visiblity.

This way,

>From you main application you can do something like this.


    if(loginWin. userInput. text=='funandlearning' && loginWin.passwordIn 
put.text= ='funandlearning')
                {
                    Alert.show("Login Successful");
                    loginWin.loginButton.visible = false
                     loginWin.logoutButton.visible = true
                }

You can also use the same button but play around the text property.

Cheers


________________________________
From: Rohit Sharma <[email protected]>
To: [email protected]
Sent: Mon, November 9, 2009 12:21:02 PM
Subject: Re: [flexcoders] Passing values from popup window to MXML component

  
  You can add a logout button at the same place as login button and toggle the 
visibilities of these buttons depending upon the
   state of your component.

   


On Mon, Nov 9, 2009 at 9:58 AM, Funand Learning <funandlearning3@ yahoo.com> 
wrote:

>
>
>
>
>
>
>
>
>
>
>
>
>
>  >
>
>>
> 
>>      
> 
>Hello All,
>
>I was trying to create a login Page. The page has one main MXML application 
>file with couple of MXML components. The First component contains the 
>following:
>
>Component1.mxml:
>
><?xml version="1.0" encoding="utf-8"?>
>
>    width="60%" height="261">
>
>    <mx:Script>
>        <![CDATA[
>>            import mx.managers. PopUpManager;
>            import mx.controls. Alert;
>            import
> components.LoginPop Up;
>            import mx.events.CloseEven t;
>            
>            public var loginWin:LoginPopUp ;
>            
>            private function loginHandler( ):void {
>                loginWin = new LoginPopUp() ;
>>                loginWin.addEventLi stener(CloseEven t.CLOSE,closeHan dler);
>                PopUpManager. addPopUp( loginWin, this,true) ;
>                PopUpManager. centerPopUp( loginWin) ;
>           
> 
>            }
>            
>            public function closeHandler( event:CloseEvent ):void
>            {
>                PopUpManager. removePopUp( loginWin) ;
>                
>            }
>            
>>        
>                public function checkCredentials( ):void{
>                
>               
> if(loginWin. userInput. text=='funandlearning' && loginWin.passwordIn 
> put.text= ='funandlearning')
>                {
>                    Alert.show("Login Successful");
>                    
>>                }
>                else
>                {
>                    Alert.show("Login Failed");
>                }
>            }
>   
>         
>        
>        ]]>
>    </mx:Script>
>
>
>    
>    <mx:HBox width="90%" height="55" borderColor="#F85023" id="headerButtons"
>        borderStyle="outset" horizontalAlign="left" verticalAlign="middle"
>>        backgroundColor="#938480">
>        <mx:Spacer width="10%"/>
>        <mx:Button id="loginMain" label="Login" click="loginHandler( )"/>
>        <mx:Button id="logout" label="LogOut" />    
>>    </mx:HBox>
>    
>    <mx:HBox width="100%" height="82%">
>        <mx:HBox width="25%"
> height="82%" borderStyle="outset" borderColor="#F85023">
>        </mx:HBox>
>        <mx:HBox width="65%" height="82%" borderColor="#F85023" 
> borderStyle="outset">
>>        </mx:HBox>
>    </mx:HBox>
></mx:VBox>
>
>component2.mxml has the following code for the popup
>
><?xml version="1.0" encoding="utf-8"?>
>
>>                xmlns:main="components.*" layout="vertical"
>          title="Please login" showCloseButton="true">
>    
>    <!-- defined state to toggle between register and login
> -->
>    <mx:states>
>        <mx:State name="Register" basedOn="">
>            <mx:AddChild relativeTo="{loginForm}"
>                         position="lastChild" creationPolicy="all">
>>                <mx:FormItem label="Email">
>                    <mx:TextInput id="email"/>
>                </mx:FormItem>
>            </mx:AddChild>
>            
>>            <mx:SetProperty
> target="{loginButton}" name="label" value="Register"/>
>            <mx:RemoveChild target="{registerLink}"/>
>            
>            <mx:AddChild relativeTo="{linkSpacer}" position="before">
>>                <mx:LinkButton label="Return to Login" 
>> click="currentState='';this.title='Please Login'"/>
>            </mx:AddChild>            
>        </mx:State>
>>    </mx:states>
>    <mx:Script>
>        <![CDATA[
>            import
> mx.events.CloseEven t;
>            import mx.managers. PopUpManager;
>            import mx.controls. Alert;
>            
>        
>        ]]>
>    </mx:Script>
>    <mx:Form id="loginForm">
>>        <mx:FormItem label="Username:">
>            <mx:TextInput id="userInput"/>
>        </mx:FormItem>
>        <mx:FormItem label="Password:">
>            <mx:TextInput id="passwordInput" displayAsPassword="true"/>
>>       
> </mx:FormItem>
>    
>    </mx:Form>
>    <mx:ControlBar>
>         <mx:LinkButton 
>            label="Need to Register?" id="registerLink"
>            click="currentState='Register';this.title='Register'"
>>        />
>        <mx:Spacer width="100%" id="linkSpacer"/>
>        <mx:Button label="Login" id="loginButton" click="checkCredentials( )"/>
>        <mx:Button label="Cancel" click="PopUpManager. removePopUp( this)"/>
>>    </mx:ControlBar>
>    
></mx:TitleWindow>
>
>I need help in knowing how to change the login button in
> component1.mxml to logout button when the login functionaility from the 
> popuup window is successful
>
>Thanks.
>
>

 


      

Reply via email to