1 Reply Latest reply on Jul 1, 2010 11:38 AM by UbuntuPenguin

    help needed to send variables


      Hello guys,


      I am developing an application that has a login system. The login is made through PHP in a component.

      Everything is ok, but I need to send the USERID from the component to the main application..


      When the component checks the login information to be ok, it makes the login component invisible and change the main application currente State. But I simply cannot send any variable from the component to the main application and use it there. I need t send the user ID as other functions among the main application will need it in order to make proper querys to the php..


      Any Ideas on how I can make the USERID variable available to use on the main application?


      This is the actionscript I am using with the component, to validate the login:


      import mx.core.Application;
      import mx.rpc.events.ResultEvent;


      // ActionScript file


      public function init():void{


      public function doLogin():void{
          if(username.text !="" && password.text !=""){
          } else {
              mensagemErro.text ="Preencha os campos para logar";


      public function resultDoLogin(e:ResultEvent):void{
          if(e.result.login =="OK"){
          } else {


              Application.application.telaLogin.mensagemErro.text = e.result.mensagem;


      and here is my login component:



      <?xml version="1.0" encoding="utf-8"?>
      <s:Panel xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:mx="library://ns.adobe.com/flex/mx" width="270" height="234" title="Cadastro" fontFamily="Verdana" fontWeight="bold" fontSize="15" chromeColor="#FFFFFF" color="#C61919">









                  protected function button1_clickHandler(event:MouseEvent):void




          <fx:Script source="as/login.as"/>
              <s:RemoteObject id="mylogin" destination="amfphp" source="login.login">
                  <s:method name="doLogin" result="resultDoLogin(event)">
          <s:Label x="11" y="46" text="CPF" fontSize="15" color="#C61919"/>
          <s:Label x="11" y="80" text="Senha&#xd;" fontSize="15" color="#C61919"/>
          <s:Label x="10" y="6" width="236" id="mensagemErro" color="#C61919" height="30" fontSize="12"/>
          <s:TextInput x="71" y="41" width="175" id="username"/>
          <s:TextInput x="71" y="75" width="175" id="password" displayAsPassword="true"/>
          <s:Button x="168" y="120" label="Enviar" click="doLogin()"  color="#C61919" chromeColor="#FFFFFF"/>
          <s:Label x="22" y="150" text="Ainda não é cadastrado?" fontSize="15" color="#C61919"/>
          <s:Button x="37" y="172" label="Crie seu cadastro!" chromeColor="#FFFFFF" focusColor="#FABABA" color="#C61919" click="button1_clickHandler(event)" skinClass="spark.skins.spark.ButtonSkin"/>





        • 1. Re: help needed to send variables
          UbuntuPenguin Level 4

          You can't send variables unless you have a stamp attached to them.  Just kidding , you can either communicate through events , or do what I usually do , store the USERID in an model/manager class .  I must advise against using Application.Application for architectural and readability reasons (how are you doing that , I thought FlexGlobals was the thing now ? ).