4 Replies Latest reply on Nov 14, 2006 11:14 AM by ntsiii

    HTTPService issues

    dr_ross Level 1
      hi all, i'm having problems scripting the HTTPService, when i use the mxml style like this

      <mx:HTTPService id="userRequest" url="check1.php" useProxy="false" method="POST">
      <mx:request xmlns="">
      <username>{username.text}</username><password>{password.text}</password><emailaddress>{em ailaddress.text}</emailaddress>

      it all works fine, but when i try and script it like this i can't seem to get a response from the server script.

      var service:HTTPService = new HTTPService();
      service.useProxy = false;
      service.method = "POST";
      service.request = {userName:username.text,password:password.text,emailaddress:emailaddress.text};
      service.addEventListener("result", authenticateHandler);

      any ideas would be much appreciated,
        • 1. Re: HTTPService issues
          Has the result made it to your "authenticateHandler(event:ResultEvent):void" function?
          • 2. Re: HTTPService issues
            ntsiii Level 3
            Exactly the correct question.


            • 3. Re: HTTPService issues
              dr_ross Level 1
              thanks for the replies,
              yeah my listener is being broadcast to now, only issues i'm having now is with the formatting of the passed event.

              heres my listener

              private function authenticateHandler(event:ResultEvent):void


              and the php that was called printed out somethinig like this

              but i can't seem to access any of the data in the result event. all i get is either null, or the old [object Object].
              I was thinking the event.result.users should be an array i could reference lik event.result.users.user[0].username but Flex really didn't like that
              • 4. Re: HTTPService issues
                ntsiii Level 3
                I advise setting the resultFormat="e4x". I believe the default is "object".

                Then in the handler do:
                var xmlResult:XML = XML(event.result);

                You should see your xml.

                The e4x XML object is very powerful, with XPath-like selection expressions that return an XMLList, which has properties similar to arrays.