1 Reply Latest reply on Mar 27, 2007 5:11 AM by Urme39

    AMFPHP + onFault function

    Urme39
      How are you supposed to use the onFault function with AMFPHP? I'm trying to use "trigger_error($errormsg);". But the onFault function in Flex 2 only prints [object Object].

      So I have probably missunderstood the entire concept with the onFault function.

      Let's say I want to add something to a database, a user. I'll send the username + email with my amfphp class. In that class I have a function that checks if the username or the email already exists, but how will I return the message to Flex 2 if one of them already exists?

      I thought the easiest way was to use: trigger_error("Username exists"); and trigger_error("E-mail exists");. But that's useless if you can't display the error msg in Flex 2.

      Can someone help a complete beginner to flex 2 and amfphp out?
        • 1. AMFPHP + onFault function
          Urme39 Level 1
          I tried this function:

          quote:


          private function onFault(e:Object) : void
          {
          mx.controls.Alert.show(ObjectUtil.toString(e));
          }


          This will display this message in the alert box:

          quote:


          (Object)#0
          code = "AMFPHP_RUNTIME_ERROR"
          description = "Wrong username or password!"
          details = "e:\projektmapp\Webb\annat\adobe flex 2 applicationer test\amfphp-1.9.beta\amfphp\services\userLogin.php"
          level = "Unknown error type"
          line = 37


          But I want to display the "description" only.

          If I try this function:
          quote:


          private function onFault(e:FaultEvent) : void
          {
          mx.controls.Alert.show(e.fault.faultString);
          }



          I'm getting an error when I run the application

          quote:


          TypeError: Error #1034: Type Coercion failed: cannot convert Object@817dd81 to mx.rpc.events.FaultEvent.



          Been trying to get this working for countless hours now, and I can't figure it out :(

          I'm triggering the error msg with this code in PHP
          quote:


          trigger_error("Wrong username or password!");