4 Replies Latest reply on Jul 7, 2006 2:37 PM by ntsiii

    httpservice last result

    Thijs
      <mx:Script>
      <![CDATA[
      public function loginFunction():void{
      loginService.send()
      var access:String = loginService.lastResult.login.access
      Alert.show(access)
      }
      ]]>
      </mx:Script>

      The HTTPService returns the variable "access", but I always get the access-variable from the previous login attempt. The access string should be made after loginService.send() was completed, so the access variable is always up to date. How can I do that?

      How can I clear the lastResult ater the login attemtp was successful?

      Thanks

        • 1. Re: httpservice last result
          Thijs Level 1
          use the result="action" tag in the HTTPService
          • 2. Re: httpservice last result
            quolo
            I'm experienceing the same problem. But being the newbie that I am, i'm confused about the result = "action" tag solution. I thought the result was an event. There is a resultFormat property, but I think that this just says what format to expect the results in. Can I see the HTTPService line of code?

            Here's what I've got that is not working.

            <mx:HTTPService id="rstSectionList" url="" useProxy="false"/>

            <mx:Script>
            <![CDATA[
            import mx.controls.Alert;

            private function FillAccordian ():void
            {
            rstSectionList.url = " http://SomePath/XMLSectionList.aspx?CircuitLevel=" + cboCircuit.selectedLabel

            rstSectionList.send();

            for each (var item:Object in rstSectionList.lastResult.CircSec.CircuitID) {
            Alert.show (item.FromBusName);

            }


            }


            ]]>
            </mx:Script>
            • 3. Re: httpservice last result
              Thijs Level 1
              ...
              rstSectionList.send();

              for each (var item:Object in rstSectionList.lastResult.CircSec.CircuitID) {
              Alert.show (item.FromBusName);
              ...

              In this situation the flash player is calling the "for each..." script while the HTTPService isn't ready yet.

              You have to create a new function:

              public function afterSend():void
              {
              for each (var item:Object in rstSectionList.lastResult.CircSec.CircuitID) {
              Alert.show (item.FromBusName);
              }

              and place the following tag in <HTTPService ... >
              result="afterSend()"

              like

              <mx:HTTPService id="rstSectionList" url="" useProxy="false" result="afterSend()"/>

              When the HTTPService is ready, the script will continue with the function afterSend with a completed data object.


              • 4. Re: httpservice last result
                ntsiii Level 3
                REmember that all Flex data retrieval is asynchronous.

                You cannot, ever, access the result data in the same function you request it.

                Result IS an event. Thijs is saying that you can only access the result data from after this event. Usually you will create an event handler function that is called by this event. This is what Thijs shows in th last example

                Tracy