views:

34

answers:

1

Hello all. My language is not the best, so try to understand me.

I have a login page (that working), if details is correct, i want to go to welcome page, and display the first name and last of the user.

Is ok to access to the label in the another page, and how can i do that please?

This is my code:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"&gt;

 <mx:Script>
  <![CDATA[

   import mx.rpc.events.ResultEvent;
   import mx.rpc.events.FaultEvent;
   import mx.controls.Alert;

   [Bindable] public var user:User;
   private function resultHandler(event:ResultEvent):void
   {
    // Is corroect to that :
    welLabel.text ="Hello "+ event.result.firstName +" "+ event.result.lastName + ", Welcome to BSRM";
    myApp.selectedChild=welcomePage;

   }

   private function faultHandler(event:FaultEvent):void
   {
    myApp.selectedChild=errorPage;
   }

  ]]>
 </mx:Script>

 <mx:RemoteObject id="ro" destination="loginService" fault="faultHandler(event)">
  <mx:method name="Login" result="resultHandler(event)"/>
 </mx:RemoteObject>
<mx:VBox label="Login Page" width="325" height="220" x="210" y="157">
 <mx:ViewStack id="myApp" height="206" width="100%">
  <mx:Canvas label="Login Page" width="100%" height="100%">
   <mx:Label text="User Name" fontWeight="bold"  x="24" y="44"/>
   <mx:Button label="Login" id="login" width="76"  x="202" y="124" click="ro.Login(userName.text,password.text)"/>
   <mx:TextInput id="userName"  x="118" y="42"/>
   <mx:Label text="Password" fontWeight="bold"  x="31" y="83"/>
   <mx:TextInput id="password"  width="160" x="118" y="81"/>
   <mx:LinkButton x="54.5" y="124" label="Forget my password" click="myApp.selectedChild=forgetPassword;"/>
   <mx:LinkButton x="206" y="163" label="New user" click="myApp.selectedChild=registerPage;"/>
  </mx:Canvas>

  <mx:Canvas id="forgetPassword" label="forgetPassword" width="100%" height="100%">
   <mx:Label x="2" y="76" text="your email" fontWeight="bold" textAlign="center"/>
   <mx:TextInput x="74" y="74" width="241"/>
   <mx:Text x="50.5" y="23" text="Forget My Password" fontWeight="bold" color="#F19114" width="224" height="26" fontSize="18"/>
   <mx:Button x="252" y="104" label="Send" color="#F9AD0B"/>

  </mx:Canvas>

  <mx:Canvas id="welcomePage" label="Welcome Page" width="100%" height="100%">
   <mx:Label id="welLabel" x="116" y="81"/>
  </mx:Canvas>

  <mx:Canvas id="errorPage" label="Error Page" width="100%" height="100%">
   <mx:Label text="Invalid user name or password"  x="82" y="85"/>
  </mx:Canvas>

  <mx:Canvas id="registerPage" label="Register Page" width="100%" height="100%">
   <mx:TextInput x="140" y="29"/>
   <mx:TextInput x="140" y="59"/>
   <mx:TextInput x="140" y="89"/>
   <mx:TextInput x="140" y="119"/>
   <mx:TextInput x="140" y="149"/>
   <mx:Label x="50" y="33" text="User name:"/>
   <mx:Label x="50" y="61" text="Password :"/>
   <mx:Label x="50" y="91" text="User name:"/>
   <mx:Label x="50" y="121" text="First name:"/>
   <mx:Label x="50" y="151" text="Last name:"/>
   <mx:Button x="140" y="176" label="Send"/>
  </mx:Canvas>

 </mx:ViewStack>
</mx:VBox> 
</mx:Application>
+1  A: 

Just give the label you want to access an ID:

<mx:Label text="User Name" fontWeight="bold"  x="24" y="44" id="lblUName/>

Then you can access it in any other part of your app:

<mx:Label id="welLabel" x="116" y="81" text="{lblUName.text}"/>
invertedSpear