1 Reply Latest reply on Apr 10, 2012 8:15 PM by aktell2007

    Change over from a simple Xml call to a rpc-Http call ....

    aktell2007 Level 1

      Hi there,

       

      I need to change over from a simple Xml call:

       

      <mx:XML id="urlsGeneral" source="http://www.mySite.com//.../AFS.xml"/>
      

       

      to a rpc-Http call which is updating the readout if Xml is changed at any time.

       

       

       

      I forgot to mention the most important item yet a very simple one: I need this only to be displayed in a title etc, and NOT a datagrid or else example below.

      title="{urlsGeneral.urlGeneral.(@name==0).age}

       

       

       

      I tried a lot today, but just can't get it right as the id="urlsGeneral" is always the problem.

       

      Any help would be appriciated !!! Thanks in advance. regards aktell2007

       

      <urlsGeneral>

       

      <urlGeneral>

      <name>Jim</name>

      <age>32</age>

      </urlGeneral>

       

      <urlGeneral>

      <name>Jim</name>

      <age>32</age>

      </urlGeneral>

       

      </urlsGeneral>

       

      Another call:

       


      <mx:Script>


      <![CDATA[







      import mx.collections.ArrayCollection;



      import mx.rpc.events.ResultEvent;







      public var myData:ArrayCollection;







      protected function myHttpService_resultHandler(event:ResultEvent):void {




      myData = event.result.urlsGeneral.urlGeneral;



      }


      ]]>

      </mx:Script>

       


      <mx:HTTPService


      id="myHttpService"


      url="http://www.mySite.com//..../AFS.xml"


      result="myHttpService_resultHandler(event)"/>

       

       

      Preferable I wanted something like this to work:

       

       


      <mx:Script>


      <![CDATA[







      import mx.rpc.events.FaultEvent;



      import mx.managers.CursorManager;



      import mx.controls.Alert;







      import mx.rpc.events.ResultEvent;



      import mx.rpc.xml.SimpleXMLDecoder;







      // Don't use here as it is already used in .swc !



      /* import mx.rpc.http.HTTPService; */







      private var myHTTP:HTTPService;







      private function initConfigCall():void {









      myHTTP = new HTTPService();









      myHTTP.url = "com/assets/data/changesAppAIRPIOne001.xml";









      myHTTP.send();




      myHTTP.resultFormat = "xml";




      myHTTP.addEventListener(ResultEvent.RESULT, resultHandler);




      myHTTP.addEventListener(FaultEvent.FAULT, faultHandler);









      CursorManager.setBusyCursor();



      }







      private function resultHandler(evt:ResultEvent):void {









      var xmlStr:String = evt.result.toString();




      var xmlDoc:XMLDocument = new XMLDocument(xmlStr);




      var decoder:SimpleXMLDecoder = new SimpleXMLDecoder(true);




      var resultObj:Object = decoder.decodeXML(xmlDoc);









      // Removed [0] on single node !




      appUpdateAvl.text = resultObj.application.configApp.appNewUpDate;




      appLastChanged.text = resultObj.application.configApp.appLastChanged;




      appChangedSections.text = resultObj.application.configApp.appChangedSections;









      CursorManager.removeBusyCursor();









      myHTTP.disconnect();



      }



      private function faultHandler(event:mx.rpc.events.FaultEvent):void {









      var faultInfo:String="fault details: "+event.fault.faultDetail+"\n\n";




      faultInfo+="fault faultString: "+event.fault.faultString+"\n\n";




      mx.controls.Alert.show(faultInfo,"Fault Information");









      var eventInfo:String="event target: "+event.target+"\n\n";




      eventInfo+="event type: "+event.type+"\n\n";




      mx.controls.Alert.show(eventInfo,"Event Information");









      CursorManager.removeBusyCursor();









      myHTTP.disconnect();





      ]]>

      </mx:Script>
        • 1. Re: Change over from a simple Xml call to a rpc-Http call ....
          aktell2007 Level 1

          Hi again,

           

          These days there are more quetions than answeres on any forum, and very seldom anybody shares the answer if they lucky enough to work it out so here is my answer for the above question

          Change over from a simple Xml call to a rpc-Http call ....

          I had it all along as a commend noted: // Removed [0] on single node !

          So instead of title="{urlsGeneral.urlGeneral.(@name==0).age} it would be now title="{resultObj.urlsGeneral.urlGeneral.[0].age} and now it works perfectly well. I hope that one or the other of you can use the answer and the code !!! regards aktell2007