2 Replies Latest reply on Mar 9, 2007 12:12 PM by kloy_fr

    Newsbies Question

    kloy_fr
      Hello,

      A have a Simple problem but i can't find a solution :

      here is my application source :

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="chargefiche()">

      <mx:HTTPService id="FicheRequest" url=" http://127.0.0.1/untec/fiche.php" useProxy="false" method="GET">
      </mx:HTTPService>
      <mx:Script>
      <![CDATA[

      private function chargefiche():void
      {
      FicheRequest.send();
      FicheLabel.text=FicheRequest.lastResult.fiches.fiche[0];
      }
      ]]>
      </mx:Script>

      <mx:Panel x="31" y="29" width="394" height="287" layout="absolute" title="test">
      <mx:Label x="10" y="10" width="354" height="227" id="FicheLabel"/>

      </mx:Panel>

      </mx:Application>


      The FicheRequest result looks like that :
      ___________________
      <fiches>
      <fiche>coucou</fiche>
      </fiches>
      ______________________

      And id like to print "coucou" inside the label FicheLabel... is it possible ?
      I've spent a lot of time on this and i cant success...

      Thx in advance.
      Nico
        • 1. Re: Newsbies Question
          ntsiii Level 3
          Flex data calls are asynchronous, so you cannot access the data in the same function in which you invoke send(). You must use a resultHandler. Also, set resultFormat="e4x". Put your data in an instance variable:
          [Bindable]private var _xmlData:XML;

          <mx:HTTPService id="FicheRequest" resultFormat="e4x" result="onResult(event)" ..>

          private function onResult(oEvent:ResultEvent):void{
          _xmlData = XML(oEvent.result);
          ...

          <mx:Label id="FicheLabel" text="{_xmlData.fiche.text()}"/>

          Tracy

          • 2. Re: Newsbies Question
            kloy_fr Level 1
            it works fine now... thanks A LOT ...