3 Replies Latest reply on Sep 16, 2010 9:15 AM by Gimp

    Setting boolean value in action script from returned java boolean

    Gimp

      Hello all,

       

      I have a actionscript function called checkLogin() which in calls a remote java method called login(). Login takes in two strings, username and password, and returns true if the combination is found in the database and false if it is not.

       

      The checkLogin function will either show an alert if the login function returns a true or it'll run a animation sequence if it is false.

       

      The trouble is that although my java login method is returning true I can't seem to set the cooresponding boolean in action script to true. The "authenticated" boolean remains as false. I know this because I used a breakpoint after it was set and used the debugger to check the variable value.

       

      I know that my remote object is setup correctly because using the network monitor function I can see the response as true.

       

      This is the button that fires off the function:

       

      <s:Button x="8" y="83" label="Login" click="checkLogin()"/>

       

      Here is my checkLogin() actionscript function:

       

      private function checkLogin():void {
                      authenticated = mainentry.login(username.text, password.text) as Boolean;
                      if(authenticated){
                          Alert.show("Logged in!");
                      }else {
                          shake.play();
                      }
                  }

       

       

      Here is my remote object declaration:

       

      <mx:RemoteObject id="mainentry" destination="Main"
                              
                               source="infrastructure.Main"
                              
                               />

       

      Here is my the output of the network monitor: (please note the correct login and password for this sample app is "admin" "admin"

       

      Request:

       

      Flex Message (flex.messaging.messages.RemotingMessage)     operation = login    clientId = null    destination = Main    messageId = B1FF60B2-40E8-2580-209D-13CF5BCB9547    timestamp = 0    timeToLive = 0    body =     [      admin,      admin    ]    hdr(DSId) = 2B5D49D7-A10B-DEA0-4A20-1D57FB576314    hdr(DSEndpoint) = my-amf

       

      Response:

       

      Flex Message (flex.messaging.messages.AcknowledgeMessageExt)     clientId = 2B5D53DD-8C0E-F45F-B5B1-19CF70CA88F6    correlationId = B1FF60B2-40E8-2580-209D-13CF5BCB9547    destination = null    messageId = 2B5D53E2-6E0F-74FC-F37C-2170EAB2DEAD    timestamp = 1284527580238    timeToLive = 0    body = true

       

      Any help would be greatly appreciated.

       

      -Felix